mirror of
https://github.com/nodejs/node.git
synced 2025-05-11 05:20:25 +00:00

`test.todo`, `test.only` and `test.skip` are expected to return the same as `test`. This commit corrects the inconsistent behavior of these shorthands. Fixes: https://github.com/nodejs/node/issues/48557 PR-URL: https://github.com/nodejs/node/pull/48555 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
'use strict';
|
|
require('../common');
|
|
|
|
// Return type of shorthands should be consistent
|
|
// with the return type of test
|
|
|
|
const assert = require('assert');
|
|
const { test, describe, it } = require('node:test');
|
|
const { isPromise } = require('util/types');
|
|
|
|
const testOnly = test('only test', { only: true });
|
|
const testTodo = test('todo test', { todo: true });
|
|
const testSkip = test('skip test', { skip: true });
|
|
const testOnlyShorthand = test.only('only test shorthand');
|
|
const testTodoShorthand = test.todo('todo test shorthand');
|
|
const testSkipShorthand = test.skip('skip test shorthand');
|
|
|
|
describe('\'node:test\' and its shorthands should return the same', () => {
|
|
it('should return a Promise', () => {
|
|
assert(isPromise(testOnly));
|
|
assert(isPromise(testTodo));
|
|
assert(isPromise(testSkip));
|
|
assert(isPromise(testOnlyShorthand));
|
|
assert(isPromise(testTodoShorthand));
|
|
assert(isPromise(testSkipShorthand));
|
|
});
|
|
|
|
it('should resolve 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);
|
|
});
|
|
});
|