diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index 2ee09c66b3e3c3..99723e62311a6f 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -16,7 +16,7 @@ const { const { exitCodes: { kGenericUserError } } = internalBinding('errors'); const { kEmptyObject } = require('internal/util'); -const { kCancelledByParent, Test, ItTest, Suite } = require('internal/test_runner/test'); +const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test'); const { kAsyncBootstrapFailure, parseCommandLine, @@ -224,7 +224,7 @@ module.exports = { createTestTree, test, describe: runInParentContext(Suite), - it: runInParentContext(ItTest), + it: runInParentContext(Test), before: hook('before'), after: hook('after'), beforeEach: hook('beforeEach'), diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 866d7d1791e298..b165808686e0ad 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -745,13 +745,6 @@ class TestHook extends Test { } } -class ItTest extends Test { - constructor(opt) { super(opt); } // eslint-disable-line no-useless-constructor - getRunArgs() { - return { ctx: { signal: this.signal, name: this.name }, args: [] }; - } -} - class Suite extends Test { constructor(options) { super(options); @@ -824,7 +817,6 @@ class Suite extends Test { } module.exports = { - ItTest, kCancelledByParent, kSubtestsFailed, kTestCodeFailure, diff --git a/test/message/test_runner_describe_it.js b/test/message/test_runner_describe_it.js index 7962f80fdd0c89..8d162c48a7305c 100644 --- a/test/message/test_runner_describe_it.js +++ b/test/message/test_runner_describe_it.js @@ -47,7 +47,7 @@ it('async throw fail', async () => { throw new Error('thrown from async throw fail'); }); -it('async skip fail', async (t) => { +it('async skip fail', async (t, done) => { t.skip(); throw new Error('thrown from async throw fail'); }); @@ -206,61 +206,61 @@ it('escaped skip message', { skip: '#skip' }); // A test whose todo message needs to be escaped. it('escaped todo message', { todo: '#todo' }); -it('callback pass', (done) => { +it('callback pass', (t, done) => { setImmediate(done); }); -it('callback fail', (done) => { +it('callback fail', (t, done) => { setImmediate(() => { done(new Error('callback failure')); }); }); -it('sync t is this in test', function() { - assert.deepStrictEqual(this, { signal: this.signal, name: this.name }); +it('sync t is this in test', function(t) { + assert.strictEqual(this, t); }); -it('async t is this in test', async function() { - assert.deepStrictEqual(this, { signal: this.signal, name: this.name }); +it('async t is this in test', async function(t) { + assert.strictEqual(this, t); }); -it('callback t is this in test', function(done) { - assert.deepStrictEqual(this, { signal: this.signal, name: this.name }); +it('callback t is this in test', function(t, done) { + assert.strictEqual(this, t); done(); }); -it('callback also returns a Promise', async (done) => { +it('callback also returns a Promise', async (t, done) => { throw new Error('thrown from callback also returns a Promise'); }); -it('callback throw', (done) => { +it('callback throw', (t, done) => { throw new Error('thrown from callback throw'); }); -it('callback called twice', (done) => { +it('callback called twice', (t, done) => { done(); done(); }); -it('callback called twice in different ticks', (done) => { +it('callback called twice in different ticks', (t, done) => { setImmediate(done); done(); }); -it('callback called twice in future tick', (done) => { +it('callback called twice in future tick', (t, done) => { setImmediate(() => { done(); done(); }); }); -it('callback async throw', (done) => { +it('callback async throw', (t, done) => { setImmediate(() => { throw new Error('thrown from callback async throw'); }); }); -it('callback async throw after done', (done) => { +it('callback async throw after done', (t, done) => { setImmediate(() => { throw new Error('thrown from callback async throw after done'); }); @@ -316,7 +316,7 @@ describe('timeouts', () => { }); }); - it('timed out callback test', { timeout: 5 }, (done) => { + it('timed out callback test', { timeout: 5 }, (t, done) => { setTimeout(done, 100); }); @@ -327,7 +327,7 @@ describe('timeouts', () => { }); }); - it('large timeout callback test is ok', { timeout: 30_000_000 }, (done) => { + it('large timeout callback test is ok', { timeout: 30_000_000 }, (t, done) => { setTimeout(done, 10); }); }); diff --git a/test/message/test_runner_describe_it.out b/test/message/test_runner_describe_it.out index 2de7664bd24d1a..b1005ff8bc0b7d 100644 --- a/test/message/test_runner_describe_it.out +++ b/test/message/test_runner_describe_it.out @@ -104,7 +104,7 @@ not ok 12 - async throw fail * ... # Subtest: async skip fail -not ok 13 - async skip fail +not ok 13 - async skip fail # SKIP --- duration_ms: * failureType: 'callbackAndPromisePresent' @@ -644,8 +644,8 @@ not ok 60 - invalid subtest fail # Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. # tests 60 # pass 23 -# fail 23 +# fail 22 # cancelled 0 -# skipped 9 +# skipped 10 # todo 5 # duration_ms *