@@ -148,6 +148,42 @@ test('skip() method with message', (t) => {
148148});
149149```
150150
151+ ## ` describe ` /` it ` syntax
152+
153+ Running tests can also be done using ` describe ` to declare a suite
154+ and ` it ` to declare a test.
155+ A suite is used to organize and group related tests together.
156+ ` it ` is an alias for ` test ` , except there is no test context passed,
157+ since nesting is done using suites, as demonstrated in this example
158+
159+ ``` js
160+ describe (' A thing' , () => {
161+ it (' should work' , () => {
162+ assert .strictEqual (1 , 1 );
163+ });
164+
165+ it (' should be ok' , () => {
166+ assert .strictEqual (2 , 2 );
167+ });
168+
169+ describe (' a nested thing' , () => {
170+ it (' should work' , () => {
171+ assert .strictEqual (3 , 3 );
172+ });
173+ });
174+ });
175+ ```
176+
177+ ` describe ` and ` it ` are imported from the ` node:test ` module
178+
179+ ``` mjs
180+ import { describe , it } from ' node:test' ;
181+ ```
182+
183+ ``` cjs
184+ const { describe , it } = require (' node:test' );
185+ ```
186+
151187### ` only ` tests
152188
153189If Node.js is started with the [ ` --test-only ` ] [ ] command-line option, it is
@@ -303,7 +339,7 @@ added: REPLACEME
303339 * ` todo ` {boolean|string} If truthy, the test marked as ` TODO ` . If a string
304340 is provided, that string is displayed in the test results as the reason why
305341 the test is ` TODO ` . ** Default:** ` false ` .
306- * ` fn ` {Function|AsyncFunction} The function under test. This first argument
342+ * ` fn ` {Function|AsyncFunction} The function under test. The first argument
307343 to this function is a [ ` TestContext ` ] [ ] object. If the test uses callbacks,
308344 the callback function is passed as the second argument. ** Default:** A no-op
309345 function.
@@ -335,6 +371,59 @@ test('top level test', async (t) => {
335371});
336372```
337373
374+ ## ` describe([name][, options][, fn]) `
375+
376+ * ` name ` {string} The name of the suite, which is displayed when reporting test
377+ results. ** Default:** The ` name ` property of ` fn ` , or ` '<anonymous>' ` if ` fn `
378+ does not have a name.
379+ * ` options ` {Object} Configuration options for the suite.
380+ supports the same options as ` test([name][, options][, fn]) `
381+ * ` fn ` {Function} The function under suite.
382+ a synchronous function declaring all subtests and subsuites.
383+ ** Default:** A no-op function.
384+ * Returns: ` undefined ` .
385+
386+ The ` describe() ` function imported from the ` node:test ` module. Each
387+ invocation of this function results in the creation of a Subtest
388+ and a test point in the TAP output.
389+ After invocation of top level ` describe ` functions,
390+ all top level tests and suites will execute
391+
392+ ## ` describe.skip([name][, options][, fn]) `
393+
394+ Shorthand for skipping a suite, same as [ ` describe([name], { skip: true }[, fn]) ` ] [ describe options ] .
395+
396+ ## ` describe.todo([name][, options][, fn]) `
397+
398+ Shorthand for marking a suite as ` TODO ` , same as
399+ [ ` describe([name], { todo: true }[, fn]) ` ] [ describe options ] .
400+
401+ ## ` it([name][, options][, fn]) `
402+
403+ * ` name ` {string} The name of the test, which is displayed when reporting test
404+ results. ** Default:** The ` name ` property of ` fn ` , or ` '<anonymous>' ` if ` fn `
405+ does not have a name.
406+ * ` options ` {Object} Configuration options for the suite.
407+ supports the same options as ` test([name][, options][, fn]) ` .
408+ * ` fn ` {Function|AsyncFunction} The function under test.
409+ If the test uses callbacks, the callback function is passed as an argument.
410+ ** Default:** A no-op function.
411+ * Returns: ` undefined ` .
412+
413+ The ` it() ` function is the value imported from the ` node:test ` module.
414+ Each invocation of this function results in the creation of a test point in the
415+ TAP output.
416+
417+ ## ` it.skip([name][, options][, fn]) `
418+
419+ Shorthand for skipping a test,
420+ same as [ ` it([name], { skip: true }[, fn]) ` ] [ it options ] .
421+
422+ ## ` it.todo([name][, options][, fn]) `
423+
424+ Shorthand for marking a test as ` TODO ` ,
425+ same as [ ` it([name], { todo: true }[, fn]) ` ] [ it options ] .
426+
338427## Class: ` TestContext `
339428
340429<!-- YAML
@@ -418,7 +507,7 @@ added: REPLACEME
418507 * ` todo ` {boolean|string} If truthy, the test marked as ` TODO ` . If a string
419508 is provided, that string is displayed in the test results as the reason why
420509 the test is ` TODO ` . ** Default:** ` false ` .
421- * ` fn ` {Function|AsyncFunction} The function under test. This first argument
510+ * ` fn ` {Function|AsyncFunction} The function under test. The first argument
422511 to this function is a [ ` TestContext ` ] [ ] object. If the test uses callbacks,
423512 the callback function is passed as the second argument. ** Default:** A no-op
424513 function.
@@ -432,4 +521,6 @@ behaves in the same fashion as the top level [`test()`][] function.
432521[ `--test` ] : cli.md#--test
433522[ `TestContext` ] : #class-testcontext
434523[ `test()` ] : #testname-options-fn
524+ [ describe options ] : #describename-options-fn
525+ [ it options ] : #testname-options-fn
435526[ test runner execution model ] : #test-runner-execution-model
0 commit comments