Skip to content

Commit

Permalink
Fix external-assertions snapshot for Node.js 20.11
Browse files Browse the repository at this point in the history
Vary the snapshots by minor version were appropriate.
  • Loading branch information
novemberborn committed Jan 28, 2024
1 parent db0fdb2 commit 15dddf3
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 12 deletions.
109 changes: 103 additions & 6 deletions test/external-assertions/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Binary file modified test/external-assertions/snapshots/test.js.snap
Binary file not shown.
15 changes: 9 additions & 6 deletions test/external-assertions/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 15dddf3

Please sign in to comment.