10

I'm trying to use Jest to aid Puppeteer testing in WebStorm.

It is my first time using Jest and it looks just the framework I need to help with testing, assertions, setup and teardown etc...

Trouble is, WebStorm won't recognise the keywords e.g. beforeAll, describe, afterAll. Here's a snippet:

enter image description here

My package.json file looks like this:

{
"name": "ui-tests",
"version": "1.0.0",
"description": "End-to-end UI tests",
"author": "John Doe",
"license": "MIT",
"dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-scripts": "1.0.17"
},
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "jest",
    "debug": "NODE_ENV=debug npm test",
    "eject": "react-scripts eject"
},
"jest": {
    "testURL": "http://localhost"
},
"devDependencies": {
    "faker": "^4.1.0",
    "jest-cli": "^22.0.4",
    "jest": "^22.0.4",
    "puppeteer": "^1.9.0"
}

}

I have the following plugins installed:

enter image description here

Any ideas?

Thanks

2
  • When you say "WebStorm won't recognize", what do you mean exactly? I have my jest.config.js file setup and configured, and when I run 'npm run test', or even just 'jest', from the builtin terminal it just runs... Nov 2, 2018 at 19:06
  • It does doesn't see "beforeAll" as a keyword; it's not highlighted like I see it in VSCode. I guess I need to learn more about the jest config file
    – Steerpike
    Nov 2, 2018 at 19:40

1 Answer 1

11

I installed "jest" library as it described here:

In Preferences | Languages & Frameworks | JavaScript | Libraries, press Download..., select 'jest' from the list of available stubs, press Download and Install

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000357324-Get-rid-of-Unresolved-function-method-variable-warning-in-Jest-test-files

That helped me with most definitions. Though I still have the same issue with "jest-puppeteer".

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.