GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: formalize fn/name as part of TestOptions API · nodejs/node@63fbd59

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • test.md
  • test/parallel
    • test-runner-option-precedence.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/test.md‎

Copy file name to clipboardExpand all lines: doc/api/test.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,10 @@ changes:
19541954
If the number of assertions run in the test does not match the number
19551955
specified in the plan, the test will fail.
19561956
**Default:** `undefined`.
1957+
* `fn` {Function|AsyncFunction} The function under test. If provided, it will take
1958+
precedence over the `fn` parameter.
1959+
* `name` {string} The name of the test. If provided, it will take precedence over the
1960+
`name` parameter.
19571961
* `fn` {Function|AsyncFunction} The function under test. The first argument
19581962
to this function is a [`TestContext`][] object. If the test uses callbacks,
19591963
the callback function is passed as the second argument. **Default:** A no-op
Collapse file

‎test/parallel/test-runner-option-precedence.js‎

Copy file name to clipboard
+41Lines 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 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.