Skip to content

Commit

Permalink
[node] adds "type" to test runner event details
Browse files Browse the repository at this point in the history
In [version 20.0.0 (and backported to 19.9.0 and 18.7.0)](nodejs/node#47094)
the test runner started reporting on whether a test was a suite. This
was exposed to reporters in the `details` object of a `test:pass` or
`test:fail` event but this hasn't been documented. This adds the `type`
property to both event's `details` object.
  • Loading branch information
philnash committed Aug 4, 2023
1 parent 0c7f509 commit 358bd51
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 8 deletions.
8 changes: 8 additions & 0 deletions types/node/test.d.ts
Expand Up @@ -1223,6 +1223,10 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -1258,6 +1262,10 @@ interface TestPass {
* The duration of the test in milliseconds.
*/
duration_ms: number;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/test/test.ts
Expand Up @@ -668,14 +668,15 @@ class TestReporter extends Transform {
case 'test:fail':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.details.error}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:pass':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:plan':
Expand Down
8 changes: 8 additions & 0 deletions types/node/ts4.8/test.d.ts
Expand Up @@ -1205,6 +1205,10 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -1240,6 +1244,10 @@ interface TestPass {
* The duration of the test in milliseconds.
*/
duration_ms: number;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/ts4.8/test/test.ts
Expand Up @@ -638,14 +638,15 @@ class TestReporter extends Transform {
case 'test:fail':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.details.error}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:pass':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:plan':
Expand Down
8 changes: 8 additions & 0 deletions types/node/v18/test.d.ts
Expand Up @@ -742,6 +742,10 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -777,6 +781,10 @@ interface TestPass {
* The duration of the test in milliseconds.
*/
duration_ms: number;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/v18/test/test.ts
Expand Up @@ -548,14 +548,15 @@ class TestReporter extends Transform {
case 'test:fail':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.details.error}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:pass':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:plan':
Expand Down
8 changes: 8 additions & 0 deletions types/node/v18/ts4.8/test.d.ts
Expand Up @@ -742,6 +742,10 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -777,6 +781,10 @@ interface TestPass {
* The duration of the test in milliseconds.
*/
duration_ms: number;
/**
* The type of the test, used to denote whether this is a suite
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/v18/ts4.8/test/test.ts
Expand Up @@ -548,14 +548,15 @@ class TestReporter extends Transform {
case 'test:fail':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.details.error}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:pass':
callback(
null,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
`${event.data.name}/${event.data.details.duration_ms}/${event.data.details.type}/
${event.data.nesting}/${event.data.testNumber}/${event.data.todo}/${event.data.skip}/${event.data.file}`,
);
break;
case 'test:plan':
Expand Down

0 comments on commit 358bd51

Please sign in to comment.