diff --git a/test/external-assertions/snapshots/test.js.md b/test/external-assertions/snapshots/test.js.md index 27ee77b13..d189b4fbc 100644 --- a/test/external-assertions/snapshots/test.js.md +++ b/test/external-assertions/snapshots/test.js.md @@ -4,7 +4,7 @@ The actual snapshot is saved in `test.js.snap`. Generated by [AVA](https://avajs.dev). -## node assertion (node.js v18) +## node assertion (node.js v^18) > Snapshot 1 @@ -46,7 +46,7 @@ Generated by [AVA](https://avajs.dev). ␊ 2 tests failed` -## expect error (node.js v18) +## expect error (node.js v^18) > Snapshot 1 @@ -96,7 +96,7 @@ Generated by [AVA](https://avajs.dev). ␊ 2 tests failed` -## node assertion (node.js v20) +## node assertion (node.js v^20 < 20.11) > Snapshot 1 @@ -138,7 +138,7 @@ Generated by [AVA](https://avajs.dev). ␊ 2 tests failed` -## expect error (node.js v20) +## expect error (node.js v^20 < 20.11) > Snapshot 1 @@ -188,7 +188,7 @@ Generated by [AVA](https://avajs.dev). ␊ 2 tests failed` -## node assertion (node.js v21) +## node assertion (node.js v^20.11) > Snapshot 1 @@ -235,7 +235,104 @@ Generated by [AVA](https://avajs.dev). ␊ 2 tests failed` -## expect error (node.js v21) +## expect error (node.js v^20.11) + +> Snapshot 1 + + `␊ + ✘ [fail]: test Assertion failed␊ + ✘ [fail]: test async Assertion failed␊ + ─␊ + ␊ + test␊ + ␊ + Assertion failed: ␊ + ␊ + expect(received).toBeTruthy()␊ + ␊ + Received: false␊ + ␊ + Error: expect(received).toBeTruthy()␊ + ␊ + Received: false␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + ␊ + ␊ + ␊ + test async␊ + ␊ + Assertion failed: ␊ + ␊ + expect(received).toBeTruthy()␊ + ␊ + Received: false␊ + ␊ + Error: expect(received).toBeTruthy()␊ + ␊ + Received: false␊ + at ---␊ + at ---␊ + ␊ + ─␊ + ␊ + 2 tests failed` + +## node assertion (node.js v^21) + +> Snapshot 1 + + `␊ + ✘ [fail]: test Assertion failed␊ + ✘ [fail]: test async Assertion failed␊ + ─␊ + ␊ + test␊ + ␊ + Assertion failed: ␊ + ␊ + The expression evaluated to a falsy value:␊ + ␊ + assert(false)␊ + ␊ + AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:␊ + ␊ + assert(false)␊ + ␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + at ---␊ + ␊ + ␊ + ␊ + test async␊ + ␊ + Assertion failed: ␊ + ␊ + false == true␊ + ␊ + AssertionError [ERR_ASSERTION]: false == true␊ + at ---␊ + at ---␊ + ␊ + ─␊ + ␊ + 2 tests failed` + +## expect error (node.js v^21) > Snapshot 1 diff --git a/test/external-assertions/snapshots/test.js.snap b/test/external-assertions/snapshots/test.js.snap index 9e22a8fa3..ceb534c96 100644 Binary files a/test/external-assertions/snapshots/test.js.snap and b/test/external-assertions/snapshots/test.js.snap differ diff --git a/test/external-assertions/test.js b/test/external-assertions/test.js index 46b7910d2..924a1f3bc 100644 --- a/test/external-assertions/test.js +++ b/test/external-assertions/test.js @@ -13,21 +13,24 @@ const snapshotStdout = (t, stdout) => { t.snapshot(normalized); }; -const major = process.versions.node.split('.')[0]; - -for (const version of ['18', '20', '21']) { +for (const [label, selector] of Object.entries({ + '^18': /^18\./, + '^20 < 20.11': /^20\.(\d\.|10\.)/, + '^20.11': /^20\.(1[1-9]\.|[2-9]\d\.)/, + '^21': /^21\./, +})) { // Tests need to be declared for all versions, so that snapshots can be // updated by running `npx test-ava -u test/external-assertions/test.js` for // each supported version. However only the tests for the current version // can run, so skip the others. - const declare = version === major ? test : test.skip; + const declare = selector.test(process.versions.node) ? test : test.skip; - declare(`node assertion (node.js v${version})`, async t => { + declare(`node assertion (node.js v${label})`, async t => { const result = await t.throwsAsync(fixture(['assert-failure.js'])); snapshotStdout(t, result.stdout); }); - declare(`expect error (node.js v${version})`, async t => { + declare(`expect error (node.js v${label})`, async t => { const result = await t.throwsAsync(fixture(['expect-failure.js'])); snapshotStdout(t, result.stdout); });