Unresolved functions or methods using CodeceptJS in PhpStorm

Viewed 1073

I've just followed the CodeceptJS Quickstart and opened first_test.js in the PhpStorm IDE (equivalent to WebStorm, IntelliJ, etc.).

For all the built-in functions, I'm getting "Unresolved function or method …":

enter image description here

I also don't get any autocompletion on I.

I've tried the following.

  1. Looked for a CodeceptJS plugin. Didn't find any.
  2. Enabled codeceptjs/node_modules in Settings -> Languages & Frameworks -> JavaScript -> Libraries.
  3. Set JavaScript language version to ECMAScript 6.
  4. Enabled the Node.js Core library.
  5. Restarted PhpStorm.
2 Answers

Please run 'npm install codeceptjs'.

I had to follow the steps outlined in https://codecept.io/typescript/ to fully enable CodeceptJS in PHPStorm.

Steps

  1. npm install codeceptjs typescript ts-node
  2. Add require('ts-node/register') as first line in my codecept.conf.js file
  3. Create a tsconfig.json in my project root folder
  4. Run npx codeceptjs def to create the default steps.d.ts file

After that, autocompletion worked in my tests :)

Related