Skip to content

Commit 89a7728

Browse files
committed
test: add test/it options precedence suite
This adds a test suite which proves the behavior of `test`/`it`'s options; specifically how the `name` and `fn` options take precedence over their associated parameters, and how a test can be named and run using only a single "options" parameter. Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
1 parent 480711f commit 89a7728

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
require('../common');
3+
const { test, suite } = require('node:test');
4+
5+
suite('test runner option precedence', () => {
6+
test(
7+
'overridden test name',
8+
{ name: 'options.name overrides test name', plan: 1 },
9+
(t) => {
10+
t.assert.strictEqual(t.name, 'options.name overrides test name');
11+
},
12+
);
13+
14+
test(
15+
'options.fn overrides test function',
16+
{
17+
fn: (t) => {
18+
t.assert.ok(true);
19+
},
20+
plan: 1,
21+
},
22+
(t) => {
23+
t.assert.fail('should not be called');
24+
},
25+
);
26+
27+
test('options.fn only', {
28+
plan: 1,
29+
fn: (t) => {
30+
t.assert.ok(true);
31+
},
32+
});
33+
34+
test({
35+
name: 'single parameter options',
36+
plan: 1,
37+
fn: (t) => {
38+
t.assert.ok(true);
39+
},
40+
});
41+
});

0 commit comments

Comments
 (0)