From 7dfa4750afce1056acbde6f5eb05a403f4b2b68a Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 24 Mar 2024 12:44:10 -0400 Subject: [PATCH] test: add test for skip+todo combinations This commit adds a regression test for the edge case where a test runner test is marked as both todo and skip. Refs: https://github.com/nodejs/node/issues/49013 PR-URL: https://github.com/nodejs/node/pull/52204 Reviewed-By: Chemi Atlow Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow --- test/parallel/test-runner-todo-skip-tests.js | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/parallel/test-runner-todo-skip-tests.js diff --git a/test/parallel/test-runner-todo-skip-tests.js b/test/parallel/test-runner-todo-skip-tests.js new file mode 100644 index 00000000000000..f4a22f5993ca85 --- /dev/null +++ b/test/parallel/test-runner-todo-skip-tests.js @@ -0,0 +1,32 @@ +'use strict'; +const common = require('../common'); +const { strictEqual } = require('node:assert'); +const { run, suite, test } = require('node:test'); + +if (!process.env.NODE_TEST_CONTEXT) { + const stream = run({ files: [__filename] }); + + stream.on('test:fail', common.mustNotCall()); + stream.on('test:pass', common.mustCall((event) => { + strictEqual(event.skip, true); + strictEqual(event.todo, undefined); + }, 4)); +} else { + test('test options only', { skip: true, todo: true }, common.mustNotCall()); + + test('test context calls only', common.mustCall((t) => { + t.todo(); + t.skip(); + })); + + test('todo test with context skip', { todo: true }, common.mustCall((t) => { + t.skip(); + })); + + // Note - there is no test for the skip option and t.todo() because the skip + // option prevents the test from running at all. This is verified by other + // tests. + + // Suites don't have the context methods, so only test the options combination. + suite('suite options only', { skip: true, todo: true }, common.mustNotCall()); +}