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 7, 2023
1 parent 0c7f509 commit fac7aea
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
10 changes: 10 additions & 0 deletions types/node/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,11 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite.
* @since 20.0.0, 19.9.0, 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -1258,6 +1263,11 @@ 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.
* @since 20.0.0, 19.9.0, 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/test/test.ts
Original file line number Diff line number Diff line change
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
10 changes: 10 additions & 0 deletions types/node/ts4.8/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,11 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite.
* @since 20.0.0, 19.9.0, 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -1240,6 +1245,11 @@ 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.
* @since 20.0.0, 19.9.0, 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/ts4.8/test/test.ts
Original file line number Diff line number Diff line change
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
10 changes: 10 additions & 0 deletions types/node/v18/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,11 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite.
* @since 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -777,6 +782,11 @@ 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.
* @since 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/v18/test/test.ts
Original file line number Diff line number Diff line change
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
10 changes: 10 additions & 0 deletions types/node/v18/ts4.8/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,11 @@ interface TestFail {
* The error thrown by the test.
*/
error: Error;
/**
* The type of the test, used to denote whether this is a suite.
* @since 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down Expand Up @@ -777,6 +782,11 @@ 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.
* @since 18.17.0
*/
type?: 'suite';
};
/**
* The test name.
Expand Down
5 changes: 3 additions & 2 deletions types/node/v18/ts4.8/test/test.ts
Original file line number Diff line number Diff line change
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 fac7aea

Please sign in to comment.