Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest snapshots work locally but consistently fail on Travis CI

My Jest snapshot tests consistently fail on Travis with the following difference:

-      "_instance": Constructor {
+      "_instance":  {

Dev dependencies include:

"babel-jest": "^19.0.0",
"jest": "^19.0.2",
"react-addons-test-utils": "^15.4.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"react-test-renderer": "^15.4.2",
"enzyme": "^2.7.1",
"enzyme-to-json": "^1.5.0",
"react": "^15.2.0",
"react-dom": "^15.2.1"

Using Node 7.0.0 locally and on Travis.

Any ideas?

like image 675
Jared Silver Avatar asked Mar 09 '17 22:03

Jared Silver


2 Answers

I would make sure that I am using the exact same version on both locally and on CI. Try pinning jest and babel-jest to a specific version:

"babel-jest": "=19.0.0",
"jest": "=19.0.2",

Maybe I would do the same with all the dependencies! Then remove node_modules/ from your machine, run the tests (update snapshots if necessary) and push.

Ps. I would also try to empty the caches on travis: https://travis-ci.com/USERNAME/REPOSITORY_NAME/caches.

like image 85
manosim Avatar answered Sep 22 '22 18:09

manosim


In my case, I had a mismatch between the node version in the build system vs local.

like image 29
ChaitanyaBhatt Avatar answered Sep 21 '22 18:09

ChaitanyaBhatt