Skip to content

Commit

Permalink
test_runner: add lifecycle:run call and make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
sankalp1999 committed May 25, 2023
1 parent 12227e5 commit 942d9a0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class Test extends AsyncResource {
this.nesting = 0;
this.only = testOnlyFlag;
this.reporter = new TestsStream();
this.reporter.begin(this.nesting, kFilename, this.testNumber, this.name, "starting", "starting");
this.runOnlySubtests = this.only;
this.testNumber = 0;
this.timeout = kDefaultTimeout;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/test_runner/tests_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestsStream extends Readable {
}

begin(nesting, file, testNumber, name, details, directive) {
this.#emit('test:begin', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
this.#emit('test:lifecycle:run', { __proto__: null, name, nesting, file, testNumber, details, ...directive });
}

fail(nesting, file, testNumber, name, details, directive) {
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-runner-reporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('node:test reporters', { concurrency: true }, () => {
testFile]);
assert.strictEqual(child.stderr.toString(), '');
const stdout = child.stdout.toString();
assert.match(stdout, /{"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/);
assert.match(stdout, /{"test:lifecycle:run":\d+,"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/);
assert.strictEqual(stdout.slice(0, filename.length + 2), `${filename} {`);
});
});
Expand All @@ -102,7 +102,7 @@ describe('node:test reporters', { concurrency: true }, () => {
assert.strictEqual(child.stderr.toString(), '');
assert.match(
child.stdout.toString(),
/^package: reporter-cjs{"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/,
/^package: reporter-cjs{"test:lifecycle:run":\d+,"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/,
);
});

Expand All @@ -113,7 +113,7 @@ describe('node:test reporters', { concurrency: true }, () => {
assert.strictEqual(child.stderr.toString(), '');
assert.match(
child.stdout.toString(),
/^package: reporter-esm{"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/,
/^package: reporter-esm{"test:lifecycle:run":\d+,"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/,
);
});

Expand Down

0 comments on commit 942d9a0

Please sign in to comment.