Jared Silver
Jared Silver

Reputation: 161

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?

Upvotes: 11

Views: 9263

Answers (2)

ChaitanyaBhatt
ChaitanyaBhatt

Reputation: 1226

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

Upvotes: 3

manosim
manosim

Reputation: 3690

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.

Upvotes: 7

Related Questions