Skip to content

Commit f7d97c5

Browse files
committed
Fix test for node 9
1 parent 83513ff commit f7d97c5

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

integration_tests/__tests__/failures.test.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,37 @@ test('not throwing Error objects', () => {
5656

5757
test('works with node assert', () => {
5858
const {stderr} = runJest(dir, ['node_assertion_error.test.js']);
59-
expect(normalizeDots(extractSummary(stderr).rest)).toMatchSnapshot();
59+
let summary = normalizeDots(extractSummary(stderr).rest);
60+
61+
// Node 9 started to include the error for `doesNotThrow`
62+
// https://github.com/nodejs/node/pull/12167
63+
if (Number(process.versions.node.split('.')[0]) >= 9) {
64+
expect(summary).toContain(`
65+
assert.doesNotThrow(function)
66+
67+
Expected the function not to throw an error.
68+
Instead, it threw:
69+
[Error: err!]
70+
71+
Message:
72+
Got unwanted exception.
73+
err!
74+
err!
75+
76+
at __tests__/node_assertion_error.test.js:71:10
77+
`);
78+
79+
summary = summary.replace(
80+
`Message:
81+
Got unwanted exception.
82+
err!
83+
err!
84+
`,
85+
`Message:
86+
Got unwanted exception.
87+
`,
88+
);
89+
}
90+
91+
expect(summary).toMatchSnapshot();
6092
});

0 commit comments

Comments
 (0)