Skip to content

Commit

Permalink
🤖 Merge PR #66282 [node] adds "type" to test runner event details by @…
Browse files Browse the repository at this point in the history
…philnash

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 11, 2023
1 parent 7c8a586 commit 15ee4f9
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
Expand Up @@ -1241,6 +1241,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 @@ -1276,6 +1281,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
Expand Up @@ -670,14 +670,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
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/ts4.8/test/test.ts
Expand Up @@ -640,14 +640,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
Expand Up @@ -756,6 +756,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 @@ -791,6 +796,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
Expand Up @@ -549,14 +549,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
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
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 15ee4f9

Please sign in to comment.