Skip to content

Commit

Permalink
test_runner: added tests for test shorthands
Browse files Browse the repository at this point in the history
Added test to check that the return type of the `todo`, `only` and `skip` shorthands
are consistent with the return type of `test`.
  • Loading branch information
shockerqt committed Jun 26, 2023
1 parent 4a32579 commit 4c8a4c5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/parallel/test-runner-typechecking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';
const common = require('../common');

// Return type of shorthands should be consistent
// with the return type of test

const assert = require('assert');
const test = require('node:test');
const { isPromise } = require('util/types');

const testOnly = test({ only: true });
const testTodo = test({ todo: true });
const testSkip = test({ skip: true });
const testOnlyShorthand = test.only();
const testTodoShorthand = test.todo();
const testSkipShorthand = test.skip();

// return Promise
assert(isPromise(testOnly));
assert(isPromise(testTodo));
assert(isPromise(testSkip));
assert(isPromise(testOnlyShorthand));
assert(isPromise(testTodoShorthand));
assert(isPromise(testSkipShorthand));

// resolve to undefined
(async () => {
assert.strictEqual(await testOnly, undefined);
assert.strictEqual(await testTodo, undefined);
assert.strictEqual(await testSkip, undefined);
assert.strictEqual(await testOnlyShorthand, undefined);
assert.strictEqual(await testTodoShorthand, undefined);
assert.strictEqual(await testSkipShorthand, undefined);
})().then(common.mustCall());

0 comments on commit 4c8a4c5

Please sign in to comment.