Skip to content

Instantly share code, notes, and snippets.

@ben-xD
Created April 19, 2020 13:20
Show Gist options
  • Save ben-xD/cccc4a1f09f07ccc52fab16a29e12065 to your computer and use it in GitHub Desktop.
Save ben-xD/cccc4a1f09f07ccc52fab16a29e12065 to your computer and use it in GitHub Desktop.
`jest --coverage` and `jest` create inconsistent snapshots
> mobile@2.8.0 test:coverage /Users/ben/butter/repos/carbonfootprint/react-native-app
> jest --coverage
PASS src/screens/__tests__/Feedback-test.js
PASS src/components/__tests__/Correction-test.js
PASS src/screens/__tests__/Login-test.js
PASS src/screens/__tests__/Signup-test.js
PASS src/components/__tests__/CarbonFootprintScore-test.js (5.73s)
PASS src/components/__tests__/MonthlyDisplay-test.js (6.377s)
PASS src/components/__tests__/WeeklyDisplay-test.js (6.418s)
PASS src/screens/__tests__/Camera-test.js
PASS src/screens/__tests__/SignupOrRegister-test.js
PASS src/screens/__tests__/Foodprint-test.js (6.578s)
PASS src/screens/__tests__/Recipe-test.js
PASS src/screens/__tests__/Settings-test.js
PASS src/screens/__tests__/Onboarding-test.js
PASS src/components/__tests__/Email-test.js
PASS src/screens/__tests__/DeleteAccount-test.js
PASS src/screens/__tests__/Loading-test.js
FAIL src/__tests__/App-test.js (7.574s)
● App renders correctly
expect(received).toMatchSnapshot()
Snapshot name: `App renders correctly 1`
- Snapshot
+ Received
@@ -42,11 +42,11 @@
onClose={[Function]}
onGestureBegin={[Function]}
onGestureCanceled={[Function]}
onOpen={[Function]}
onTransitionStart={[Function]}
- pointerEvents="none"
+ pointerEvents="box-none"
style={
Object {
"bottom": 0,
"left": 0,
"position": "absolute",
@@ -99,11 +99,11 @@
"transform": Array [
Object {
"translateX": 0,
},
Object {
- "translateX": -33.152236746157065,
+ "translateX": -15.068613022373556,
},
],
}
}
>
@@ -260,11 +260,11 @@
style={
Object {
"flex": 1,
"transform": Array [
Object {
- "translateX": 639.4925441794765,
+ "translateX": 699.7712899254215,
},
Object {
"translateX": 0,
},
],
@@ -282,11 +282,11 @@
"shadowColor": "#000",
"shadowOffset": Object {
"height": 1,
"width": -1,
},
- "shadowOpacity": 0.04420298232820941,
+ "shadowOpacity": 0.020091484029831408,
"shadowRadius": 5,
"top": 0,
"width": 3,
}
}
125 |
126 | expect(mockedUseNetInfo).toBeCalledTimes(1);
> 127 | expect(app).toMatchSnapshot();
| ^
128 | });
129 |
130 |
at _callee2$ (src/__tests__/App-test.js:127:15)
at tryCatch (node_modules/regenerator-runtime/runtime.js:45:17)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:264:22)
at Generator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:98:21)
at tryCatch (node_modules/regenerator-runtime/runtime.js:45:17)
at invoke (node_modules/regenerator-runtime/runtime.js:137:20)
at node_modules/regenerator-runtime/runtime.js:147:13
at tryCallOne (node_modules/promise/lib/core.js:35:12)
at node_modules/promise/lib/core.js:136:15
at flush (node_modules/asap/raw.js:51:25)
› 1 snapshot failed.
--------------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
--------------------------|----------|----------|----------|----------|-------------------|
All files | 49.4 | 35.38 | 40.4 | 48.98 | |
src | 95.24 | 56.25 | 100 | 94.74 | |
App.js | 95.24 | 56.25 | 100 | 94.74 | 70 |
src/components | 91.09 | 75.71 | 94.12 | 90.91 | |
CarbonFootprintScore.js | 69.23 | 50 | 100 | 69.23 |... 22,27,29,31,35 |
Email.js | 83.33 | 100 | 66.67 | 83.33 | 16 |
MonthlyDisplay.js | 100 | 84.62 | 100 | 100 | 54,63,80 |
Password.js | 100 | 100 | 100 | 100 | |
WeeklyDisplay.js | 100 | 84.62 | 100 | 100 | 54,60,80 |
src/images | 100 | 100 | 100 | 100 | |
full-smiley.png | 100 | 100 | 100 | 100 | |
logo.png | 100 | 100 | 100 | 100 | |
logoGreen.png | 100 | 100 | 100 | 100 | |
unimpressed-smiley.png | 100 | 100 | 100 | 100 | |
src/screens | 34.86 | 18.85 | 23.68 | 34.86 | |
Camera.js | 44.44 | 26.67 | 33.33 | 44.44 |... 42,61,62,67,74 |
Correction.js | 47.62 | 25 | 20 | 47.62 |... 41,56,57,64,88 |
DeleteAccount.js | 15.79 | 0 | 0 | 15.79 |... 37,49,60,61,63 |
Feedback.js | 5 | 0 | 0 | 5 |... 46,252,256,259 |
Foodprint.js | 6.58 | 0 | 0 | 6.58 |... 34,235,236,238 |
Loading.js | 100 | 100 | 100 | 100 | |
Login.js | 88 | 75 | 100 | 88 | 33,34,35 |
Onboarding.js | 80 | 100 | 50 | 80 | 36 |
Recipe.js | 66.67 | 50 | 66.67 | 66.67 |... 8,67,76,86,111 |
Settings.js | 13.33 | 100 | 0 | 13.33 |... 27,28,33,57,68 |
Signup.js | 88 | 75 | 100 | 88 | 36,37,38 |
SignupOrRegister.js | 90.48 | 100 | 60 | 90.48 | 71,80 |
--------------------------|----------|----------|----------|----------|-------------------|
Snapshot Summary
› 1 snapshot failed from 1 test suite. Inspect your code changes or run `npm run test:coverage -- -u` to update them.
Test Suites: 1 failed, 16 passed, 17 total
Tests: 1 failed, 27 passed, 28 total
Snapshots: 1 failed, 20 passed, 21 total
Time: 9.859s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mobile@2.8.0 test:coverage: `jest --coverage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mobile@2.8.0 test:coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ben/.npm/_logs/2020-04-19T13_20_00_890Z-debug.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment