| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b209f6b commit 2479553
16 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1627,6 +1627,8 @@ If no arguments are passed in at all `message` will be set to the string: | |||
| 1627 | 1627 | Be aware that in the `repl` the error message will be different to the one | |
| 1628 | 1628 | thrown in a file! See below for further details. | |
| 1629 | 1629 | ||
| 1630 | + <!-- eslint-skip --> | ||
| 1631 | + | ||
| 1630 | 1632 | ```mjs | |
| 1631 | 1633 | import assert from 'node:assert/strict'; | |
| 1632 | 1634 | ||
@@ -1662,6 +1664,8 @@ assert.ok(0); | |||
| 1662 | 1664 | // assert.ok(0) | |
| 1663 | 1665 | ``` | |
| 1664 | 1666 | ||
| 1667 | + <!-- eslint-skip --> | ||
| 1668 | + | ||
| 1665 | 1669 | ```cjs | |
| 1666 | 1670 | const assert = require('node:assert/strict'); | |
| 1667 | 1671 | ||
@@ -1701,20 +1705,20 @@ assert.ok(0); | |||
| 1701 | 1705 | import assert from 'node:assert/strict'; | |
| 1702 | 1706 | ||
| 1703 | 1707 | // Using `assert()` works the same: | |
| 1704 | - assert(0); | ||
| 1708 | + assert(2 + 2 > 5); | ||
| 1705 | 1709 | // AssertionError: The expression evaluated to a falsy value: | |
| 1706 | 1710 | // | |
| 1707 | - // assert(0) | ||
| 1711 | + // assert(2 + 2 > 5) | ||
| 1708 | 1712 | ``` | |
| 1709 | 1713 | ||
| 1710 | 1714 | ```cjs | |
| 1711 | 1715 | const assert = require('node:assert'); | |
| 1712 | 1716 | ||
| 1713 | 1717 | // Using `assert()` works the same: | |
| 1714 | - assert(0); | ||
| 1718 | + assert(2 + 2 > 5); | ||
| 1715 | 1719 | // AssertionError: The expression evaluated to a falsy value: | |
| 1716 | 1720 | // | |
| 1717 | - // assert(0) | ||
| 1721 | + // assert(2 + 2 > 5) | ||
| 1718 | 1722 | ``` | |
| 1719 | 1723 | ||
| 1720 | 1724 | ## `assert.rejects(asyncFn[, error][, message])` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1786,7 +1786,7 @@ This function creates a hook that runs before executing a suite. | |||
| 1786 | 1786 | describe('tests', async () => { | |
| 1787 | 1787 | before(() => console.log('about to run some test')); | |
| 1788 | 1788 | it('is a subtest', () => { | |
| 1789 | - assert.ok('some relevant assertion here'); | ||
| 1789 | + // Some relevant assertions here | ||
| 1790 | 1790 | }); | |
| 1791 | 1791 | }); | |
| 1792 | 1792 | ``` | |
@@ -1816,7 +1816,7 @@ This function creates a hook that runs after executing a suite. | |||
| 1816 | 1816 | describe('tests', async () => { | |
| 1817 | 1817 | after(() => console.log('finished running tests')); | |
| 1818 | 1818 | it('is a subtest', () => { | |
| 1819 | - assert.ok('some relevant assertion here'); | ||
| 1819 | + // Some relevant assertion here | ||
| 1820 | 1820 | }); | |
| 1821 | 1821 | }); | |
| 1822 | 1822 | ``` | |
@@ -1849,7 +1849,7 @@ This function creates a hook that runs before each test in the current suite. | |||
| 1849 | 1849 | describe('tests', async () => { | |
| 1850 | 1850 | beforeEach(() => console.log('about to run a test')); | |
| 1851 | 1851 | it('is a subtest', () => { | |
| 1852 | - assert.ok('some relevant assertion here'); | ||
| 1852 | + // Some relevant assertion here | ||
| 1853 | 1853 | }); | |
| 1854 | 1854 | }); | |
| 1855 | 1855 | ``` | |
@@ -1880,7 +1880,7 @@ The `afterEach()` hook is run even if the test fails. | |||
| 1880 | 1880 | describe('tests', async () => { | |
| 1881 | 1881 | afterEach(() => console.log('finished running a test')); | |
| 1882 | 1882 | it('is a subtest', () => { | |
| 1883 | - assert.ok('some relevant assertion here'); | ||
| 1883 | + // Some relevant assertion here | ||
| 1884 | 1884 | }); | |
| 1885 | 1885 | }); | |
| 1886 | 1886 | ``` | |
@@ -3472,7 +3472,7 @@ test('top level test', async (t) => { | |||
| 3472 | 3472 | await t.test( | |
| 3473 | 3473 | 'This is a subtest', | |
| 3474 | 3474 | (t) => { | |
| 3475 | - assert.ok('some relevant assertion here'); | ||
| 3475 | + // Some relevant assertion here | ||
| 3476 | 3476 | }, | |
| 3477 | 3477 | ); | |
| 3478 | 3478 | }); | |
@@ -3503,7 +3503,7 @@ finishes. | |||
| 3503 | 3503 | ```js | |
| 3504 | 3504 | test('top level test', async (t) => { | |
| 3505 | 3505 | t.after((t) => t.diagnostic(`finished running ${t.name}`)); | |
| 3506 | - assert.ok('some relevant assertion here'); | ||
| 3506 | + // Some relevant assertion here | ||
| 3507 | 3507 | }); | |
| 3508 | 3508 | ``` | |
| 3509 | 3509 | ||
@@ -3535,7 +3535,7 @@ test('top level test', async (t) => { | |||
| 3535 | 3535 | await t.test( | |
| 3536 | 3536 | 'This is a subtest', | |
| 3537 | 3537 | (t) => { | |
| 3538 | - assert.ok('some relevant assertion here'); | ||
| 3538 | + // Some relevant assertion here | ||
| 3539 | 3539 | }, | |
| 3540 | 3540 | ); | |
| 3541 | 3541 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,7 +97,7 @@ function getDecoder(decoder, encoding) { | |||
| 97 | 97 | if (normalizedEncoding === undefined) { | |
| 98 | 98 | throw new ERR_UNKNOWN_ENCODING(encoding); | |
| 99 | 99 | } | |
| 100 | - assert(false, 'Cannot change encoding'); | ||
| 100 | + assert.fail('Cannot change encoding'); | ||
| 101 | 101 | } | |
| 102 | 102 | return decoder; | |
| 103 | 103 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ exec(...cmdline, common.mustCall((err, stdout, stderr) => { | |||
| 36 | 36 | if (!err) { | |
| 37 | 37 | console.log(stdout); | |
| 38 | 38 | console.log(stderr); | |
| 39 | - assert(false, 'this test should fail'); | ||
| 39 | + assert.fail('this test should fail'); | ||
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | 42 | assert(common.nodeProcessAborted(err.code, err.signal)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,4 +4,4 @@ | |||
| 4 | 4 | require('../common'); | |
| 5 | 5 | ||
| 6 | 6 | const assert = require('internal/assert'); | |
| 7 | - assert(false); | ||
| 7 | + assert(2 + 2 > 5); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,7 +102,7 @@ if (!id) { | |||
| 102 | 102 | })); | |
| 103 | 103 | }, 2)); | |
| 104 | 104 | } else { | |
| 105 | - assert(0); // Bad command line argument | ||
| 105 | + assert.fail('Bad command line argument'); | ||
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | 108 | function startWorker() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,5 +58,5 @@ if (id === 'undefined') { | |||
| 58 | 58 | })); | |
| 59 | 59 | })); | |
| 60 | 60 | } else { | |
| 61 | - assert(0); // Bad argument. | ||
| 61 | + assert.fail('Bad argument'); | ||
| 62 | 62 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,10 +181,6 @@ assert.throws(() => { | |||
| 181 | 181 | assert.ok(stream.write('hello world 👀\n')); | |
| 182 | 182 | assert.ok(stream.write('another line 👀\n')); | |
| 183 | 183 | ||
| 184 | - // Check internal buffer length (may not be available in Utf8Stream) | ||
| 185 | - // This is implementation-specific, so we just verify writes succeeded | ||
| 186 | - assert.ok(true, 'writes completed successfully'); | ||
| 187 | - | ||
| 188 | 184 | stream.end(); | |
| 189 | 185 | } | |
| 190 | 186 | ||
@@ -200,7 +196,6 @@ assert.throws(() => { | |||
| 200 | 196 | } | |
| 201 | 197 | ||
| 202 | 198 | // Check internal buffer length (implementation-specific) | |
| 203 | - assert.ok(true, 'writes completed successfully'); | ||
| 204 | 199 | readFile(dest, 'utf8', common.mustSucceed((data) => { | |
| 205 | 200 | assert.strictEqual(data, str); | |
| 206 | 201 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -529,7 +529,6 @@ describe('glob - with restricted directory', function() { | |||
| 529 | 529 | for await (const match of asyncGlob('*', { cwd: restrictedDir })) { | |
| 530 | 530 | results.push(match); | |
| 531 | 531 | } | |
| 532 | - assert.ok(true, 'glob completed without throwing on readdir error'); | ||
| 533 | 532 | } finally { | |
| 534 | 533 | try { | |
| 535 | 534 | chmodSync(restrictedDir, 0o755); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ const server = http.Server(common.mustCall((req, res) => { | |||
| 46 | 46 | assert.strictEqual(req.headers.cookie, 'abc=123; def=456; ghi=789'); | |
| 47 | 47 | break; | |
| 48 | 48 | default: | |
| 49 | - assert(false, `Unexpected request for ${req.url}`); | ||
| 49 | + assert.fail(`Unexpected request for ${req.url}`); | ||
| 50 | 50 | } | |
| 51 | 51 | ||
| 52 | 52 | if (expectedRequests.length === 0) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments