Create multiple Testcases in the specified Testset.
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: 'My API Key',
});
const testcase = await client.testcases.create('246', {
items: [
{
jsonData: {
question: 'What is the capital of France?',
idealAnswer: 'Paris',
provenance: 'hand_curated',
},
},
{
jsonData: {
question: 'What is the largest planet in our solar system?',
idealAnswer: 'Jupiter',
provenance: 'synthetic',
},
},
{
jsonData: {
question: 'How many planets are in our solar system?',
idealAnswer: 8,
provenance: 'user_feedback',
},
},
],
});
console.log(testcase.items);{
"items": [
{
"id": "123",
"testsetId": "246",
"jsonData": {
"question": "What is the capital of France?",
"idealAnswer": "Paris",
"provenance": "hand_curated"
},
"inputs": {
"question": "What is the capital of France?"
},
"expected": {
"idealAnswer": "Paris"
}
},
{
"id": "124",
"testsetId": "246",
"jsonData": {
"question": "What is the largest planet in our solar system?",
"idealAnswer": "Jupiter",
"provenance": "synthetic"
},
"inputs": {
"question": "What is the largest planet in our solar system?"
},
"expected": {
"idealAnswer": "Jupiter"
}
},
{
"id": "125",
"testsetId": "246",
"jsonData": {
"question": "How many planets are in our solar system?",
"idealAnswer": 8,
"provenance": "user_feedback"
},
"inputs": {
"question": "How many planets are in our solar system?"
},
"expected": {
"idealAnswer": 8
},
"validationErrors": [
{
"path": "/data/idealAnswer",
"message": "Expected string, received number"
}
]
}
]
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The ID of the Testset to add the Testcases to.
"246"
Testcases created successfully
Show child attributes
The ID of the Testcase.
The ID of the Testset this Testcase belongs to.
The JSON data of the Testcase, which is validated against the Testset's schema.
Derived from data based on the Testset's fieldMapping. Contains all fields marked as inputs, including those with validation errors.
Derived from data based on the Testset's fieldMapping. Contains all fields marked as expected outputs, including those with validation errors.
Validation errors found in the Testcase data. If present, the Testcase doesn't fully conform to its Testset's schema.
Was this page helpful?
import Scorecard from 'scorecard-ai';
const client = new Scorecard({
apiKey: 'My API Key',
});
const testcase = await client.testcases.create('246', {
items: [
{
jsonData: {
question: 'What is the capital of France?',
idealAnswer: 'Paris',
provenance: 'hand_curated',
},
},
{
jsonData: {
question: 'What is the largest planet in our solar system?',
idealAnswer: 'Jupiter',
provenance: 'synthetic',
},
},
{
jsonData: {
question: 'How many planets are in our solar system?',
idealAnswer: 8,
provenance: 'user_feedback',
},
},
],
});
console.log(testcase.items);{
"items": [
{
"id": "123",
"testsetId": "246",
"jsonData": {
"question": "What is the capital of France?",
"idealAnswer": "Paris",
"provenance": "hand_curated"
},
"inputs": {
"question": "What is the capital of France?"
},
"expected": {
"idealAnswer": "Paris"
}
},
{
"id": "124",
"testsetId": "246",
"jsonData": {
"question": "What is the largest planet in our solar system?",
"idealAnswer": "Jupiter",
"provenance": "synthetic"
},
"inputs": {
"question": "What is the largest planet in our solar system?"
},
"expected": {
"idealAnswer": "Jupiter"
}
},
{
"id": "125",
"testsetId": "246",
"jsonData": {
"question": "How many planets are in our solar system?",
"idealAnswer": 8,
"provenance": "user_feedback"
},
"inputs": {
"question": "How many planets are in our solar system?"
},
"expected": {
"idealAnswer": 8
},
"validationErrors": [
{
"path": "/data/idealAnswer",
"message": "Expected string, received number"
}
]
}
]
}