Using jest in my react app, describe is not defined
ReactjsJestjsEslintEslintrcReactjs Problem Overview
I am new to jest and trying to figure out some basic stuff in my following code
import * as actions from './IncrementalSearchActions';
describe('Incremental Search Actions', () => {
it('Should create an incremental search action')
});
The questions/confusions I have around this are
- I get an error saying describe is not defined, how do I import the reuqired module?
- Is this supposed to be used with Karma/Jasmine?
Reactjs Solutions
Solution 1 - Reactjs
I believe the answer here is the answer to your question.
TL;DR;:
add the following to your .eslintrc
file:
"env": {
"jest": true
}
Solution 2 - Reactjs
Are your test files under a the "test" folder? make sure jest is install properly and listed on your package.json and under scripts have:
"test": "jest --coverage",
you can run the script with npm test