3

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.
Yngve Høiseth
  • 570
  • 6
  • 26

2 Answers2

2

Please run 'npm install codeceptjs'.

Oksana
  • 662
  • 3
  • 2
  • Great, thanks. I find it a bit strange that this makes a difference, considering that I have installed `codeceptjs-webdriverio` which in turn depends on `codeceptjs`. – Yngve Høiseth Sep 28 '17 at 19:29
  • 3
    @YngveHøiseth As I understand it's the way how IDE is indexing the `node_modules` -- it only indexes modules that YOU are required (in your `package.json` or whatever that file is) and ignores packages (excludes folders) if they are not used directly (e.g. used by other libs internally). This is to avoid polluting completion with most-likely-unneeded-for-you libs/functions (since they may be used only inside that lib). If you need something -- require it directly (make it your direct dependency). – LazyOne Sep 29 '17 at 13:34
  • This does not fix the problem. The functions are not imported and phpstorm will still think they are non existant – gempir Jun 26 '19 at 11:47
0

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 :)

Philipp
  • 10,240
  • 8
  • 59
  • 71