Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jest in my react app, describe is not defined

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

  1. I get an error saying describe is not defined, how do I import the reuqired module?
  2. Is this supposed to be used with Karma/Jasmine?
like image 827
tmp dev Avatar asked Jun 18 '17 02:06

tmp dev


People also ask

Do you need Enzyme with Jest?

Jest can be used without Enzyme to render components and test with snapshots, Enzyme simply adds additional functionality. Enzyme can be used without Jest, however Enzyme must be paired with another test runner if Jest is not used.

Can you test react with Jest?

Jest is a JavaScript testing framework that allows developers to run tests on JavaScript and TypeScript code and can be easily integrated with React JS. Open the package. json, and you will find that when you use create-react-app for creating a react project, it has default support for jest and react testing library.

Is Jest included in Create react app?

Create React App uses Jest as its test runner. To prepare for this integration, we did a major revamp of Jest so if you heard bad things about it years ago, give it another try.

Do you need Jest for react testing library?

React Testing Library is not specific to any testing framework; we can use it with any other testing library, although Jest is recommended and preferred by many developers. create-react-app uses both Jest and React Testing Library by default.


1 Answers

I believe the answer here is the answer to your question.

TL;DR;:

add the following to your .eslintrc file:

"env": {     "jest": true } 
like image 74
SunshinyDoyle Avatar answered Oct 10 '22 08:10

SunshinyDoyle