| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 07036cf commit 762dc7c
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -156,8 +156,7 @@ test('skip() method with message', (t) => { | |||
| 156 | 156 | Running tests can also be done using `describe` to declare a suite | |
| 157 | 157 | and `it` to declare a test. | |
| 158 | 158 | A suite is used to organize and group related tests together. | |
| 159 | - `it` is an alias for `test`, except there is no test context passed, | ||
| 160 | - since nesting is done using suites. | ||
| 159 | + `it` is a shorthand for [`test()`][]. | ||
| 161 | 160 | ||
| 162 | 161 | ```js | |
| 163 | 162 | describe('A thing', () => { | |
@@ -841,17 +840,19 @@ Shorthand for marking a suite as `only`, same as | |||
| 841 | 840 | ||
| 842 | 841 | ## `it([name][, options][, fn])` | |
| 843 | 842 | ||
| 844 | - * `name` {string} The name of the test, which is displayed when reporting test | ||
| 845 | - results. **Default:** The `name` property of `fn`, or `'<anonymous>'` if `fn` | ||
| 846 | - does not have a name. | ||
| 847 | - * `options` {Object} Configuration options for the suite. | ||
| 848 | - supports the same options as `test([name][, options][, fn])`. | ||
| 849 | - * `fn` {Function|AsyncFunction} The function under test. | ||
| 850 | - If the test uses callbacks, the callback function is passed as an argument. | ||
| 851 | - **Default:** A no-op function. | ||
| 852 | - * Returns: `undefined`. | ||
| 843 | + <!-- YAML | ||
| 844 | + added: | ||
| 845 | + - v18.6.0 | ||
| 846 | + - v16.17.0 | ||
| 847 | + changes: | ||
| 848 | + - version: REPLACEME | ||
| 849 | + pr-url: https://github.com/nodejs/node/pull/46889 | ||
| 850 | + description: Calling `it()` is now equivalent to calling `test()`. | ||
| 851 | + --> | ||
| 852 | + | ||
| 853 | + Shorthand for [`test()`][]. | ||
| 853 | 854 | ||
| 854 | - The `it()` function is the value imported from the `node:test` module. | ||
| 855 | + The `it()` function is imported from the `node:test` module. | ||
| 855 | 856 | ||
| 856 | 857 | ## `it.skip([name][, options][, fn])` | |
| 857 | 858 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ const { | |||
| 16 | 16 | const { exitCodes: { kGenericUserError } } = internalBinding('errors'); | |
| 17 | 17 | ||
| 18 | 18 | const { kEmptyObject } = require('internal/util'); | |
| 19 | - const { kCancelledByParent, Test, ItTest, Suite } = require('internal/test_runner/test'); | ||
| 19 | + const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test'); | ||
| 20 | 20 | const { | |
| 21 | 21 | kAsyncBootstrapFailure, | |
| 22 | 22 | parseCommandLine, | |
@@ -218,7 +218,7 @@ module.exports = { | |||
| 218 | 218 | createTestTree, | |
| 219 | 219 | test, | |
| 220 | 220 | describe: runInParentContext(Suite), | |
| 221 | - it: runInParentContext(ItTest), | ||
| 221 | + it: runInParentContext(Test), | ||
| 222 | 222 | before: hook('before'), | |
| 223 | 223 | after: hook('after'), | |
| 224 | 224 | beforeEach: hook('beforeEach'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -731,13 +731,6 @@ class TestHook extends Test { | |||
| 731 | 731 | } | |
| 732 | 732 | } | |
| 733 | 733 | ||
| 734 | - class ItTest extends Test { | ||
| 735 | - constructor(opt) { super(opt); } // eslint-disable-line no-useless-constructor | ||
| 736 | - getRunArgs() { | ||
| 737 | - return { ctx: { signal: this.signal, name: this.name }, args: [] }; | ||
| 738 | - } | ||
| 739 | - } | ||
| 740 | - | ||
| 741 | 734 | class Suite extends Test { | |
| 742 | 735 | constructor(options) { | |
| 743 | 736 | super(options); | |
@@ -810,7 +803,6 @@ class Suite extends Test { | |||
| 810 | 803 | } | |
| 811 | 804 | ||
| 812 | 805 | module.exports = { | |
| 813 | - ItTest, | ||
| 814 | 806 | kCancelledByParent, | |
| 815 | 807 | kSubtestsFailed, | |
| 816 | 808 | kTestCodeFailure, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ const { describe, it } = require('node:test'); | |||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | 11 | describe('ESM: REPL runs', { concurrency: true }, () => { | |
| 12 | - it((done) => { | ||
| 12 | + it((t, done) => { | ||
| 13 | 13 | const child = spawn(execPath, [ | |
| 14 | 14 | '--interactive', | |
| 15 | 15 | ], { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,7 @@ it('async throw fail', async () => { | |||
| 47 | 47 | throw new Error('thrown from async throw fail'); | |
| 48 | 48 | }); | |
| 49 | 49 | ||
| 50 | - it('async skip fail', async (t) => { | ||
| 50 | + it('async skip fail', async (t, done) => { | ||
| 51 | 51 | t.skip(); | |
| 52 | 52 | throw new Error('thrown from async throw fail'); | |
| 53 | 53 | }); | |
@@ -206,61 +206,61 @@ it('escaped skip message', { skip: '#skip' }); | |||
| 206 | 206 | // A test whose todo message needs to be escaped. | |
| 207 | 207 | it('escaped todo message', { todo: '#todo' }); | |
| 208 | 208 | ||
| 209 | - it('callback pass', (done) => { | ||
| 209 | + it('callback pass', (t, done) => { | ||
| 210 | 210 | setImmediate(done); | |
| 211 | 211 | }); | |
| 212 | 212 | ||
| 213 | - it('callback fail', (done) => { | ||
| 213 | + it('callback fail', (t, done) => { | ||
| 214 | 214 | setImmediate(() => { | |
| 215 | 215 | done(new Error('callback failure')); | |
| 216 | 216 | }); | |
| 217 | 217 | }); | |
| 218 | 218 | ||
| 219 | - it('sync t is this in test', function() { | ||
| 220 | - assert.deepStrictEqual(this, { signal: this.signal, name: this.name }); | ||
| 219 | + it('sync t is this in test', function(t) { | ||
| 220 | + assert.strictEqual(this, t); | ||
| 221 | 221 | }); | |
| 222 | 222 | ||
| 223 | - it('async t is this in test', async function() { | ||
| 224 | - assert.deepStrictEqual(this, { signal: this.signal, name: this.name }); | ||
| 223 | + it('async t is this in test', async function(t) { | ||
| 224 | + assert.strictEqual(this, t); | ||
| 225 | 225 | }); | |
| 226 | 226 | ||
| 227 | - it('callback t is this in test', function(done) { | ||
| 228 | - assert.deepStrictEqual(this, { signal: this.signal, name: this.name }); | ||
| 227 | + it('callback t is this in test', function(t, done) { | ||
| 228 | + assert.strictEqual(this, t); | ||
| 229 | 229 | done(); | |
| 230 | 230 | }); | |
| 231 | 231 | ||
| 232 | - it('callback also returns a Promise', async (done) => { | ||
| 232 | + it('callback also returns a Promise', async (t, done) => { | ||
| 233 | 233 | throw new Error('thrown from callback also returns a Promise'); | |
| 234 | 234 | }); | |
| 235 | 235 | ||
| 236 | - it('callback throw', (done) => { | ||
| 236 | + it('callback throw', (t, done) => { | ||
| 237 | 237 | throw new Error('thrown from callback throw'); | |
| 238 | 238 | }); | |
| 239 | 239 | ||
| 240 | - it('callback called twice', (done) => { | ||
| 240 | + it('callback called twice', (t, done) => { | ||
| 241 | 241 | done(); | |
| 242 | 242 | done(); | |
| 243 | 243 | }); | |
| 244 | 244 | ||
| 245 | - it('callback called twice in different ticks', (done) => { | ||
| 245 | + it('callback called twice in different ticks', (t, done) => { | ||
| 246 | 246 | setImmediate(done); | |
| 247 | 247 | done(); | |
| 248 | 248 | }); | |
| 249 | 249 | ||
| 250 | - it('callback called twice in future tick', (done) => { | ||
| 250 | + it('callback called twice in future tick', (t, done) => { | ||
| 251 | 251 | setImmediate(() => { | |
| 252 | 252 | done(); | |
| 253 | 253 | done(); | |
| 254 | 254 | }); | |
| 255 | 255 | }); | |
| 256 | 256 | ||
| 257 | - it('callback async throw', (done) => { | ||
| 257 | + it('callback async throw', (t, done) => { | ||
| 258 | 258 | setImmediate(() => { | |
| 259 | 259 | throw new Error('thrown from callback async throw'); | |
| 260 | 260 | }); | |
| 261 | 261 | }); | |
| 262 | 262 | ||
| 263 | - it('callback async throw after done', (done) => { | ||
| 263 | + it('callback async throw after done', (t, done) => { | ||
| 264 | 264 | setImmediate(() => { | |
| 265 | 265 | throw new Error('thrown from callback async throw after done'); | |
| 266 | 266 | }); | |
@@ -316,7 +316,7 @@ describe('timeouts', () => { | |||
| 316 | 316 | }); | |
| 317 | 317 | }); | |
| 318 | 318 | ||
| 319 | - it('timed out callback test', { timeout: 5 }, (done) => { | ||
| 319 | + it('timed out callback test', { timeout: 5 }, (t, done) => { | ||
| 320 | 320 | setTimeout(done, 100); | |
| 321 | 321 | }); | |
| 322 | 322 | ||
@@ -327,7 +327,7 @@ describe('timeouts', () => { | |||
| 327 | 327 | }); | |
| 328 | 328 | }); | |
| 329 | 329 | ||
| 330 | - it('large timeout callback test is ok', { timeout: 30_000_000 }, (done) => { | ||
| 330 | + it('large timeout callback test is ok', { timeout: 30_000_000 }, (t, done) => { | ||
| 331 | 331 | setTimeout(done, 10); | |
| 332 | 332 | }); | |
| 333 | 333 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,7 @@ not ok 12 - async throw fail | |||
| 104 | 104 | * | |
| 105 | 105 | ... | |
| 106 | 106 | # Subtest: async skip fail | |
| 107 | - not ok 13 - async skip fail | ||
| 107 | + not ok 13 - async skip fail # SKIP | ||
| 108 | 108 | --- | |
| 109 | 109 | duration_ms: * | |
| 110 | 110 | failureType: 'callbackAndPromisePresent' | |
@@ -644,8 +644,8 @@ not ok 60 - invalid subtest fail | |||
| 644 | 644 | # Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event. | |
| 645 | 645 | # tests 60 | |
| 646 | 646 | # pass 23 | |
| 647 | - # fail 23 | ||
| 647 | + # fail 22 | ||
| 648 | 648 | # cancelled 0 | |
| 649 | - # skipped 9 | ||
| 649 | + # skipped 10 | ||
| 650 | 650 | # todo 5 | |
| 651 | 651 | # duration_ms * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments