Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: todo, only, skip are expected to return a Promise #48555

Merged
merged 3 commits into from
Jul 3, 2023
Rate limit · GitHub

Whoa there!

You have triggered an abuse detection mechanism.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test_runner: change tests to use describe/it
Rate limit · GitHub

Whoa there!

You have triggered an abuse detection mechanism.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

shockerqt committed Jun 27, 2023
commit cf59fa00fb6c4d6c60b97a2ce07ec73149d8bed3
50 changes: 26 additions & 24 deletions test/parallel/test-runner-typechecking.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
'use strict';
const common = require('../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 { test, describe, it } = 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();
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');

// return Promise
assert(isPromise(testOnly));
assert(isPromise(testTodo));
assert(isPromise(testSkip));
assert(isPromise(testOnlyShorthand));
assert(isPromise(testTodoShorthand));
assert(isPromise(testSkipShorthand));
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));
});

// 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());
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);
});
});