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.

2 Answers 2

2

Please run 'npm install codeceptjs'.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
@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).
This does not fix the problem. The functions are not imported and phpstorm will still think they are non existant
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 :)

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.