shallow() fails because of RSTTraversal unavailable
up vote
0
down vote
favorite
I am trying to get started with jest and doing snapshot tests. I have actually had this working in the past, I came and saw the below error, so i proceeded to read around and upgrade packages where I could, but still I am getting the error.
Splash.test.js
import shallow from 'enzyme';
import shallowToJson from 'enzyme-to-json';
import Splash from './Splash';
it('Splash page is rendered', () =>
const result = shallow(
<Splash />,
);
expect(shallowToJson(result)).toMatchSnapshot();
);
Terminal Output
> jest
FAIL src/components/Splash/Splash.test.js
● Test suite failed to run
Cannot find module 'enzyme/build/RSTTraversal' from 'shallow.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:194:17)
at Object.<anonymous> (node_modules/enzyme-to-json/shallow.js:15:21)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.83s
Ran all test suites.
Large Package.json
....
"scripts":
"test": "jest",
,
"dependencies":
"enzyme": "^2.9.1",
"react": "^15.5.0",
"react-addons-test-utils": "^15.5.0",
"react-css-modules": "^4.1.0",
"react-dom": "^15.5.0",
"react-redux": "^5.0.3",
"react-router": "^4.1.1",
"react-router-dom": "^4.0.0",
"react-router-page-transition": "^3.0.2",
"react-router-redux": "^5.0.0-alpha.6",
"react-tap-event-plugin": "^2.0.1",
"react-test-renderer": "^15.5.4",
"redux": "^3.6.0",
"webpack": "^2.2.1"
......
,
"devDependencies":
......
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-jest": "^22.0.6",
"babel-loader": "^6.4.0",
"babel-plugin-dynamic-import-node": "^1.1.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-react-css-modules": "^3.3.0",
"babel-plugin-transform-react-require": "^1.0.1",
"babel-plugin-transform-react-stateless-component-name": "^1.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"babel-runtime": "^6.23.0",
"enzyme-to-json": "^3.3.0",
"jest": "^22.0.6",
"jest-cli": "^22.0.6",
"jest-enzyme": "^4.0.2",
"react-hot-loader": "^3.0.0-beta.7",
"redux-actions": "^2.2.1",
"redux-devtools-extension": "^2.13.2",
"redux-form": "^6.7.0",
"redux-logger": "^3.0.0",
"redux-persist": "^4.8.0",
"regenerator-runtime": "^0.11.0",
"require-hacker": "^3.0.0",
"resolve-url-loader": "^2.0.2",
"style-loader": "^0.16.0",
"svg-react-loader": "^0.4.5",
"url-loader": "^0.5.8",
"webpack-config": "^7.0.0",
"webpack-dashboard": "^0.3.0",
"webpack-dev-server": "^2.4.2"
,
......
"jest":
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"moduleFileExtensions": [
"js"
],
"moduleDirectories": [
"node_modules"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/app/"
],
"moduleNameMapper":
"moduleNameMapper":
"\.(jpg
,
"transform":
"^.+\.js$": "babel-jest"
javascript npm jestjs enzyme
add a comment |
up vote
0
down vote
favorite
I am trying to get started with jest and doing snapshot tests. I have actually had this working in the past, I came and saw the below error, so i proceeded to read around and upgrade packages where I could, but still I am getting the error.
Splash.test.js
import shallow from 'enzyme';
import shallowToJson from 'enzyme-to-json';
import Splash from './Splash';
it('Splash page is rendered', () =>
const result = shallow(
<Splash />,
);
expect(shallowToJson(result)).toMatchSnapshot();
);
Terminal Output
> jest
FAIL src/components/Splash/Splash.test.js
● Test suite failed to run
Cannot find module 'enzyme/build/RSTTraversal' from 'shallow.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:194:17)
at Object.<anonymous> (node_modules/enzyme-to-json/shallow.js:15:21)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.83s
Ran all test suites.
Large Package.json
....
"scripts":
"test": "jest",
,
"dependencies":
"enzyme": "^2.9.1",
"react": "^15.5.0",
"react-addons-test-utils": "^15.5.0",
"react-css-modules": "^4.1.0",
"react-dom": "^15.5.0",
"react-redux": "^5.0.3",
"react-router": "^4.1.1",
"react-router-dom": "^4.0.0",
"react-router-page-transition": "^3.0.2",
"react-router-redux": "^5.0.0-alpha.6",
"react-tap-event-plugin": "^2.0.1",
"react-test-renderer": "^15.5.4",
"redux": "^3.6.0",
"webpack": "^2.2.1"
......
,
"devDependencies":
......
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-jest": "^22.0.6",
"babel-loader": "^6.4.0",
"babel-plugin-dynamic-import-node": "^1.1.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-react-css-modules": "^3.3.0",
"babel-plugin-transform-react-require": "^1.0.1",
"babel-plugin-transform-react-stateless-component-name": "^1.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"babel-runtime": "^6.23.0",
"enzyme-to-json": "^3.3.0",
"jest": "^22.0.6",
"jest-cli": "^22.0.6",
"jest-enzyme": "^4.0.2",
"react-hot-loader": "^3.0.0-beta.7",
"redux-actions": "^2.2.1",
"redux-devtools-extension": "^2.13.2",
"redux-form": "^6.7.0",
"redux-logger": "^3.0.0",
"redux-persist": "^4.8.0",
"regenerator-runtime": "^0.11.0",
"require-hacker": "^3.0.0",
"resolve-url-loader": "^2.0.2",
"style-loader": "^0.16.0",
"svg-react-loader": "^0.4.5",
"url-loader": "^0.5.8",
"webpack-config": "^7.0.0",
"webpack-dashboard": "^0.3.0",
"webpack-dev-server": "^2.4.2"
,
......
"jest":
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"moduleFileExtensions": [
"js"
],
"moduleDirectories": [
"node_modules"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/app/"
],
"moduleNameMapper":
"moduleNameMapper":
"\.(jpg
,
"transform":
"^.+\.js$": "babel-jest"
javascript npm jestjs enzyme
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to get started with jest and doing snapshot tests. I have actually had this working in the past, I came and saw the below error, so i proceeded to read around and upgrade packages where I could, but still I am getting the error.
Splash.test.js
import shallow from 'enzyme';
import shallowToJson from 'enzyme-to-json';
import Splash from './Splash';
it('Splash page is rendered', () =>
const result = shallow(
<Splash />,
);
expect(shallowToJson(result)).toMatchSnapshot();
);
Terminal Output
> jest
FAIL src/components/Splash/Splash.test.js
● Test suite failed to run
Cannot find module 'enzyme/build/RSTTraversal' from 'shallow.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:194:17)
at Object.<anonymous> (node_modules/enzyme-to-json/shallow.js:15:21)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.83s
Ran all test suites.
Large Package.json
....
"scripts":
"test": "jest",
,
"dependencies":
"enzyme": "^2.9.1",
"react": "^15.5.0",
"react-addons-test-utils": "^15.5.0",
"react-css-modules": "^4.1.0",
"react-dom": "^15.5.0",
"react-redux": "^5.0.3",
"react-router": "^4.1.1",
"react-router-dom": "^4.0.0",
"react-router-page-transition": "^3.0.2",
"react-router-redux": "^5.0.0-alpha.6",
"react-tap-event-plugin": "^2.0.1",
"react-test-renderer": "^15.5.4",
"redux": "^3.6.0",
"webpack": "^2.2.1"
......
,
"devDependencies":
......
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-jest": "^22.0.6",
"babel-loader": "^6.4.0",
"babel-plugin-dynamic-import-node": "^1.1.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-react-css-modules": "^3.3.0",
"babel-plugin-transform-react-require": "^1.0.1",
"babel-plugin-transform-react-stateless-component-name": "^1.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"babel-runtime": "^6.23.0",
"enzyme-to-json": "^3.3.0",
"jest": "^22.0.6",
"jest-cli": "^22.0.6",
"jest-enzyme": "^4.0.2",
"react-hot-loader": "^3.0.0-beta.7",
"redux-actions": "^2.2.1",
"redux-devtools-extension": "^2.13.2",
"redux-form": "^6.7.0",
"redux-logger": "^3.0.0",
"redux-persist": "^4.8.0",
"regenerator-runtime": "^0.11.0",
"require-hacker": "^3.0.0",
"resolve-url-loader": "^2.0.2",
"style-loader": "^0.16.0",
"svg-react-loader": "^0.4.5",
"url-loader": "^0.5.8",
"webpack-config": "^7.0.0",
"webpack-dashboard": "^0.3.0",
"webpack-dev-server": "^2.4.2"
,
......
"jest":
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"moduleFileExtensions": [
"js"
],
"moduleDirectories": [
"node_modules"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/app/"
],
"moduleNameMapper":
"moduleNameMapper":
"\.(jpg
,
"transform":
"^.+\.js$": "babel-jest"
javascript npm jestjs enzyme
I am trying to get started with jest and doing snapshot tests. I have actually had this working in the past, I came and saw the below error, so i proceeded to read around and upgrade packages where I could, but still I am getting the error.
Splash.test.js
import shallow from 'enzyme';
import shallowToJson from 'enzyme-to-json';
import Splash from './Splash';
it('Splash page is rendered', () =>
const result = shallow(
<Splash />,
);
expect(shallowToJson(result)).toMatchSnapshot();
);
Terminal Output
> jest
FAIL src/components/Splash/Splash.test.js
● Test suite failed to run
Cannot find module 'enzyme/build/RSTTraversal' from 'shallow.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:194:17)
at Object.<anonymous> (node_modules/enzyme-to-json/shallow.js:15:21)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.83s
Ran all test suites.
Large Package.json
....
"scripts":
"test": "jest",
,
"dependencies":
"enzyme": "^2.9.1",
"react": "^15.5.0",
"react-addons-test-utils": "^15.5.0",
"react-css-modules": "^4.1.0",
"react-dom": "^15.5.0",
"react-redux": "^5.0.3",
"react-router": "^4.1.1",
"react-router-dom": "^4.0.0",
"react-router-page-transition": "^3.0.2",
"react-router-redux": "^5.0.0-alpha.6",
"react-tap-event-plugin": "^2.0.1",
"react-test-renderer": "^15.5.4",
"redux": "^3.6.0",
"webpack": "^2.2.1"
......
,
"devDependencies":
......
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-jest": "^22.0.6",
"babel-loader": "^6.4.0",
"babel-plugin-dynamic-import-node": "^1.1.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-react-css-modules": "^3.3.0",
"babel-plugin-transform-react-require": "^1.0.1",
"babel-plugin-transform-react-stateless-component-name": "^1.1.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"babel-runtime": "^6.23.0",
"enzyme-to-json": "^3.3.0",
"jest": "^22.0.6",
"jest-cli": "^22.0.6",
"jest-enzyme": "^4.0.2",
"react-hot-loader": "^3.0.0-beta.7",
"redux-actions": "^2.2.1",
"redux-devtools-extension": "^2.13.2",
"redux-form": "^6.7.0",
"redux-logger": "^3.0.0",
"redux-persist": "^4.8.0",
"regenerator-runtime": "^0.11.0",
"require-hacker": "^3.0.0",
"resolve-url-loader": "^2.0.2",
"style-loader": "^0.16.0",
"svg-react-loader": "^0.4.5",
"url-loader": "^0.5.8",
"webpack-config": "^7.0.0",
"webpack-dashboard": "^0.3.0",
"webpack-dev-server": "^2.4.2"
,
......
"jest":
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"moduleFileExtensions": [
"js"
],
"moduleDirectories": [
"node_modules"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/app/"
],
"moduleNameMapper":
"moduleNameMapper":
"\.(jpg
,
"transform":
"^.+\.js$": "babel-jest"
javascript npm jestjs enzyme
javascript npm jestjs enzyme
edited Nov 11 at 18:12
skyboyer
3,14111128
3,14111128
asked Jan 14 at 19:53
Jamie Hutber
13.3k2396167
13.3k2396167
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
I got this same error when I have a version mis-match between my enzyme and enzyme-to-json. You either need to upgrade enzyme or downgrade enzyme-to-json.
I currently have two different combinations working in different projects:
enzyme 2.8.2 & enzyme-to-json 1.5.0
enzyme 3.3.0 & enzyme-to-json 3.3.0
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
added above in answer
– keithjgrant
Mar 6 at 18:40
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
add a comment |
up vote
0
down vote
Try to replace your shallowToJson
import to:
import shallowToJson from 'enzyme-to-json';
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I got this same error when I have a version mis-match between my enzyme and enzyme-to-json. You either need to upgrade enzyme or downgrade enzyme-to-json.
I currently have two different combinations working in different projects:
enzyme 2.8.2 & enzyme-to-json 1.5.0
enzyme 3.3.0 & enzyme-to-json 3.3.0
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
added above in answer
– keithjgrant
Mar 6 at 18:40
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
add a comment |
up vote
1
down vote
accepted
I got this same error when I have a version mis-match between my enzyme and enzyme-to-json. You either need to upgrade enzyme or downgrade enzyme-to-json.
I currently have two different combinations working in different projects:
enzyme 2.8.2 & enzyme-to-json 1.5.0
enzyme 3.3.0 & enzyme-to-json 3.3.0
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
added above in answer
– keithjgrant
Mar 6 at 18:40
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I got this same error when I have a version mis-match between my enzyme and enzyme-to-json. You either need to upgrade enzyme or downgrade enzyme-to-json.
I currently have two different combinations working in different projects:
enzyme 2.8.2 & enzyme-to-json 1.5.0
enzyme 3.3.0 & enzyme-to-json 3.3.0
I got this same error when I have a version mis-match between my enzyme and enzyme-to-json. You either need to upgrade enzyme or downgrade enzyme-to-json.
I currently have two different combinations working in different projects:
enzyme 2.8.2 & enzyme-to-json 1.5.0
enzyme 3.3.0 & enzyme-to-json 3.3.0
edited Mar 6 at 18:40
answered Mar 2 at 16:08
keithjgrant
8,47843774
8,47843774
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
added above in answer
– keithjgrant
Mar 6 at 18:40
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
add a comment |
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
added above in answer
– keithjgrant
Mar 6 at 18:40
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
Please could you give the version numbers you're currently using for it to work.
– Jamie Hutber
Mar 3 at 10:47
added above in answer
– keithjgrant
Mar 6 at 18:40
added above in answer
– keithjgrant
Mar 6 at 18:40
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
using versions 3.3.0 fro answer still gives the problem. Using React Native. (enzyme-adapter-react-16@1.1.1) peer dep missing: enzyme@^2.7.1, required by enzyme-to-json@1.6.0
– Alan
Mar 23 at 13:00
add a comment |
up vote
0
down vote
Try to replace your shallowToJson
import to:
import shallowToJson from 'enzyme-to-json';
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
add a comment |
up vote
0
down vote
Try to replace your shallowToJson
import to:
import shallowToJson from 'enzyme-to-json';
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
add a comment |
up vote
0
down vote
up vote
0
down vote
Try to replace your shallowToJson
import to:
import shallowToJson from 'enzyme-to-json';
Try to replace your shallowToJson
import to:
import shallowToJson from 'enzyme-to-json';
edited Aug 22 at 23:03
Bharata
7,12041030
7,12041030
answered Jan 16 at 16:47
toufek khoury
34014
34014
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
add a comment |
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
I like our thinking, but doing it my way would return undefined. So I have the same error with ur way I'm afraid
– Jamie Hutber
Jan 16 at 20:14
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48253555%2fshallow-fails-because-of-rsttraversal-unavailable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown