From 15dddf3ff5407b6941cf320bcb60720ac4d24a9c Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 28 Jan 2024 21:05:36 +0100 Subject: [PATCH] Fix external-assertions snapshot for Node.js 20.11 Vary the snapshots by minor version were appropriate. --- test/external-assertions/snapshots/test.js.md | 109 +++++++++++++++++- .../snapshots/test.js.snap | Bin 441 -> 481 bytes test/external-assertions/test.js | 15 ++- 3 files changed, 112 insertions(+), 12 deletions(-) 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 9e22a8fa3329dde379bc8e2829c2c18d22d71e8f..ceb534c96d669d68907c5847dde81f030b592da9 100644 GIT binary patch literal 481 zcmV<70UrKARzVyI3O#sHNOO@=Wlg3u z8nR_~TiTo6d;kv~ywqp$4SWNiM0VRMElsN^O~C9W?Ck8$&d--0cHFrRsdvjCUQh%g z#NmEKeFVZeG7-=SbU82Ia2Q-xkBopvq{q8d@cXgv6G1NWZ(F&YoE-V>+-~7DuK~P2 zKS8TQg0O9aKrW#Ed7O-*zbuFFQRFSne7w^%P)YK;m|=sAc1Xw(YBdn7k8^1a#wdeU z!*Q2*4Cu=1e*I&*HRbZ)3P%d_HfukPXMYi>rg0| zb0`!G$)GT~v(C`NV1T|+7W4#N))(E8ZpZ{@x-!*ChLn!>&$p(Vn{+6#4zg0b<5(3q z2CGu8Rx{`MU(Rz7=R7Ns$Q&qT{G>yPb+ExI2Z|x>aE`Q6LZrD}ltMA&TrS~&gnc5= z2SI@-T}B{dXlqK6Nsqb`%=pg#{ObZ~rZX{jE5^H9W^9?U{h6_?c+6Rut7WdXq1WPa X)-p>=7dPopA`Y?-*MIK*sS*GHd9vYC literal 441 zcmV;q0Y?5oRzV{5rbZ}8fyGSW=CU0pp zSysA_znCda@SO8NvTq>H{_OZ?>+bDefZ^>_HSbz+{>poq=;f1 zA0|9RU{a!>h$mpHdG$_0T03(hnXsW8aFUPHFl5B8%O5+Xy^=W z&!V{J0ih&lexIhQ80Kl1oFqZ6^7+BCK#SCOS>b`I_E{_u8Vw*Z!Ub7N2ri)8^8K4; zyWR3T7gv`(Z)pSQ!3bQ}{kMrVZ)?{37MlBUx2_)|vuo!p9N>6}0Rif3){szf7f3j& zY=?x|lWl { 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); });