Reputation: 170
I am using JEST framework for unit testing. I am using Shallow from enzyme for DOM testing. I am getting the following warning after running jest command.
PASS tests/CheckboxWithLabel-test.js
● Console console.error node_modules/fbjs/lib/warning.js:36 Warning: Shallow renderer has been moved to react-test-renderer/shallow. Update references to remove this warning.
My test is
import React from 'react';
import {shallow} from 'enzyme';
import CheckboxWithLabel from '../app/Component8/CheckboxWithLabel';
test('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow(
<CheckboxWithLabel labelOn="On" labelOff="Off" />
);
expect(checkbox.text()).toEqual('Off');
checkbox.find('input').simulate('change');
expect(checkbox.text()).toEqual('On');
});
My package.json
{
"name": "myapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"linkify-it": "^2.0.3",
"prop-types": "^15.5.8",
"react": "16.0.0-alpha.6",
"react-dom": "^15.4.2",
"react-native": "0.43.1"
},
"devDependencies": {
"babel-jest": "19.0.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-react-native": "1.9.1",
"enzyme": "^2.8.2",
"jest": "19.0.2",
"react-addons-test-utils": "~15.1.0",
"react-test-renderer": "16.0.0-alpha.6"
},
"jest": {
"preset": "react-native"
}
}
Upvotes: 0
Views: 717
Reputation: 841
From the Enzyme docs:
If you are using React >=15.5, in addition to enzyme, you will have to ensure that you also have the following npm modules installed if they were not already:
npm i --save-dev react-test-renderer react-dom
Upvotes: 1