-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed as not planned
Description
🐛 Bug Report
A unit test is failing in one environment but not others. The output is very unhelpful because the serialized results look identical.
To Reproduce
Created a unit tests against captured console output using toMatchSnapshot()
.
expect(getLog().log).toMatchSnapshot()
The results of running this test look like this:
[2020-04-22T17:27:08.927Z] FAIL src/__tests__/logger.test.js
[2020-04-22T17:27:08.927Z] ● Console logging › Logs error level and above.
[2020-04-22T17:27:08.927Z]
[2020-04-22T17:27:08.927Z] expect(received).toMatchSnapshot()
[2020-04-22T17:27:08.927Z]
[2020-04-22T17:27:08.927Z] Snapshot name: `Console logging Logs error level and above. 1`
[2020-04-22T17:27:08.927Z]
[2020-04-22T17:27:08.927Z] Snapshot: "[error]: Testing simple message at error level... "
[2020-04-22T17:27:08.927Z] Received: "[error]: Testing simple message at error level... "
From this result I cannot fathom what is wrong with the matcher. As far as I know, this is not a custom matcher. .log
is declared as a TS string
type.
As of right now I have no idea how to reproduce since the error has given me no indication of what is not matching.
Expected behavior
Output either matches and succeeds or provides a clear indication of how the matcher failed.
Link to repl or repo (highly encouraged)
No way to reproduce outside environment at the moment. No idea what is wrong because the error message is completely opaque.
envinfo
[2020-04-22T18:10:43.171Z] + npx envinfo --preset jest
[2020-04-22T18:10:44.515Z] npx: installed 1 in 1.119s
[2020-04-22T18:10:44.765Z]
[2020-04-22T18:10:44.765Z] System:
[2020-04-22T18:10:44.765Z] OS: Linux 4.14 Alpine Linux
[2020-04-22T18:10:44.765Z] CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
[2020-04-22T18:10:44.765Z] Binaries:
[2020-04-22T18:10:44.765Z] Node: 12.16.2 - /usr/local/bin/node
[2020-04-22T18:10:44.765Z] Yarn: 1.22.4 - /usr/local/bin/yarn
[2020-04-22T18:10:44.765Z] npm: 6.14.4 - /usr/local/bin/npm
[2020-04-22T18:10:44.765Z] npmPackages:
[2020-04-22T18:10:44.765Z] jest: ^25.4.0 => 25.4.0
[2020-04-22T18:10:44.765Z]
rluvaton