Skip to content

debugF ileF ormat

The Testomatio Reporter debug file format is used to capture and replay test execution data. This specification defines the structure, storage location, and content of debug files.

Debug files use JSONL (JSON Lines) format, not standard JSON. Each line contains a single JSON object representing a specific action or data entry. This format allows for streaming processing and incremental writing.

{"t":"+0ms","datetime":"2024-01-15T10:30:00.000Z","timestamp":1705315800000}
{"t":"+5ms","data":"variables","testomatioEnvVars":{"TESTOMATIO":"abc123"}}
{"t":"+10ms","action":"createRun","params":{"title":"Test Run"}}

Debug files are stored in the system’s temporary directory:

Primary File (timestamped):

{os.tmpdir()}/testomatio.debug.{timestamp}.json

Example: /tmp/testomatio.debug.1705315800000.json

Symlink (latest):

{os.tmpdir()}/testomatio.debug.latest.json

The symlink always points to the most recently created debug file, providing a consistent access point for tools like the replay command.

  • Files are created when TESTOMATIO_DEBUG or DEBUG environment variables are set
  • A new timestamped file is created for each test session
  • The symlink is updated to point to the latest file
  • If symlink creation fails, it’s logged but doesn’t prevent file creation

Every entry in the debug file follows this base structure:

{
"t": "+{time}ms", // Time elapsed since last action (required)
// ... action-specific fields
}
  • Format: "+{milliseconds}ms" (e.g., "+150ms", "+2.5s")
  • Represents time passed since the previous action
  • Generated using prettyMs() for human readability

Timestamp Entry:

{
"t": "+0ms",
"datetime": "2024-01-15T10:30:00.000Z",
"timestamp": 1705315800000
}

Environment Variables:

{
"t": "+5ms",
"data": "variables",
"testomatioEnvVars": {
"TESTOMATIO": "api_key_here",
"TESTOMATIO_TITLE": "Test Run Title",
"TESTOMATIO_ENV": "staging"
}
}

Store Data:

{
"t": "+10ms",
"data": "store",
"store": {}
}

Prepare Run:

{
"t": "+15ms",
"action": "prepareRun",
"data": {
"pipe": "testomatio",
"pipeOptions": "tag-name=smoke"
}
}

Create Run:

{
"t": "+20ms",
"action": "createRun",
"params": {
"title": "Test Run Title",
"env": "staging",
"parallel": true,
"isBatchEnabled": true
}
}

Finish Run:

{
"t": "+5000ms",
"actions": "finishRun",
"params": {
"status": "finished",
"parallel": true
}
}

Add Single Test:

{
"t": "+100ms",
"action": "addTest",
"runId": "run-id-uuid",
"testId": {
"id": "test-unique-id",
"title": "Test case title",
"status": "passed",
"time": 1500,
"rid": "request-id",
"suite": "Suite Name",
"file": "path/to/test.js",
"error": "Error message if failed",
"steps": [
{
"title": "Step description",
"status": "passed",
"time": 500
}
],
"artifacts": [
{
"name": "screenshot.png",
"type": "image/png",
"path": "/path/to/screenshot.png"
}
],
"files": [
"/path/to/attachment1.txt",
"/path/to/attachment2.log"
]
}
}

Add Tests Batch:

{
"t": "+200ms",
"action": "addTestsBatch",
"runId": "run-id-uuid",
"tests": [
{
"id": "test-1",
"title": "First test",
"status": "passed",
"time": 800
},
{
"id": "test-2",
"title": "Second test",
"status": "failed",
"time": 1200,
"error": "Assertion failed"
}
]
}
FieldTypeRequiredDescription
tstringYesTime elapsed since last action (e.g., “+150ms”)
actionstringConditionalAction type identifier (most actions)
actionsstringConditionalAction type identifier (for finishRun only)
datastringConditionalData type identifier for non-action entries
FieldTypeRequiredDescription
paramsobjectYesParameters for run creation/completion
params.titlestringNoTest run title
params.envstringNoEnvironment name
params.parallelbooleanNoWhether run supports parallel execution
params.statusstringNoRun status (for finishRun)
params.isBatchEnabledbooleanNoWhether batch upload is enabled
FieldTypeRequiredDescription
runIdstringNoUUID of the test run
testIdobjectYes*Single test data (for addTest)
testsarrayYes*Array of test objects (for addTestsBatch)

*Either testId or tests is required depending on action type.

FieldTypeRequiredDescription
idstringYesUnique test identifier
titlestringYesTest case title
statusstringYesTest status: “passed”, “failed”, “skipped”, “pending”
timenumberNoExecution time in milliseconds
ridstringNoRequest ID for deduplication
suitestringNoTest suite name
filestringNoTest file path
errorstringNoError message for failed tests
stackstringNoStack trace for failed tests
codestringNoTest source code
stepsarrayNoArray of test step objects
artifactsarrayNoArray of artifact objects
filesarrayNoArray of file paths
FieldTypeRequiredDescription
titlestringYesStep description
statusstringYesStep status
timenumberNoStep execution time
errorstringNoError message for failed steps
FieldTypeRequiredDescription
namestringYesArtifact file name
typestringNoMIME type
pathstringNoFile system path
urlstringNoRemote URL
sizenumberNoFile size in bytes
FieldTypeRequiredDescription
datastringYesMust be “variables”
testomatioEnvVarsobjectYesAll TESTOMATIO_* environment variables
FieldTypeRequiredDescription
datastringYesMust be “store”
storeobjectYesInternal store data
  • "passed" - Test executed successfully
  • "failed" - Test failed with assertion or runtime error
  • "skipped" - Test was skipped intentionally
  • "pending" - Test is pending implementation
  • "retried" - Test was retried
  • "started" - Run has been initiated
  • "finished" - Run completed normally
  • "failed" - Run failed due to system error
  • "interrupted" - Run was interrupted
  1. Each line must be valid JSON
  2. Empty lines and whitespace-only lines are ignored
  3. Parse errors are logged but don’t stop processing
  4. Maximum of 3 parse errors are shown, then summarized
  • Tests with rid (request ID) are deduplicated
  • Multiple entries with same rid are merged
  • Later entries can override earlier fields
  • Arrays (files, artifacts) are merged, not replaced
  • Tests without rid are never deduplicated

When merging duplicate tests:

  1. Non-null/non-undefined values override null/undefined
  2. Non-empty arrays override empty arrays
  3. Files and artifacts arrays are concatenated
  4. Other fields use “last value wins” strategy
Terminal window
export TESTOMATIO_DEBUG=1
export DEBUG=1
npm test
Terminal window
npx testomatio-reporter replay
npx testomatio-reporter replay /tmp/testomatio.debug.1705315800000.json
import fs from 'fs';
// Read debug file line by line
const content = fs.readFileSync('/tmp/testomatio.debug.latest.json', 'utf-8');
const lines = content.trim().split('\n').filter(line => line.trim());
for (const line of lines) {
try {
const entry = JSON.parse(line);
console.log(`[${entry.t}] ${entry.action || entry.data}`);
} catch (err) {
console.error('Parse error:', err.message);
}
}
  • Debug files are created in the DebugPipe constructor when enabled
  • Each test session gets a unique timestamped filename
  • Symlink provides consistent access to the latest file
  • Tests can be logged individually or in batches
  • Batch interval is 5 seconds by default
  • Batch upload is triggered on intervals and during finishRun
  • Parse errors don’t stop file processing
  • Missing required fields may cause replay failures
  • Malformed entries are skipped with warnings
  • Files are written synchronously for data integrity
  • Large test suites may produce substantial debug files
  • Consider file cleanup policies for long-running systems

This specification is compatible with:

  • Testomatio Reporter v2.0.0+
  • All major test frameworks (Jest, Mocha, Playwright, etc.)
  • Node.js 14+ environments
  • Debug files may contain sensitive data from environment variables
  • Store debug files securely and clean them regularly
  • Consider filtering sensitive variables before logging
  • Debug files are world-readable by default in temp directories