Skip to content

Latest commit

 

History

History
122 lines (76 loc) · 7.87 KB

File metadata and controls

122 lines (76 loc) · 7.87 KB

← Back to documentation

Frequently asked questions

I get fs_1.promises.rm is not a function

Upgrade your node version to v18.0.0, which is the minimum required version.

I get state.messages.current.findLastIndex is not a function

Upgrade your node version to v18.0.0, which is the minimum required version.

--env / tags isn't picked up

This might be because you're trying to specify -e / --env multiple times, but multiple values should be comma-separated.

Negated tags / complex tag expressions aren't working as expected on Windows

Windows / CMD.EXE users must be aware that single-quotes bear no special meaning and should not be used to group words in your shell. For these users, only double-quotes should be used for this purpose. What this means is that, for these users, running cypress run --env tags='not @foo' is not going to behave and double-quotes must be used. Furthermore, similar scripts contained in package.json should also use double-quotes (escaped necessarily, as that is JSON).

JSON reports aren't generated in open / interactive mode

JSON reports aren't generated in open / interactive mode. They rely on some events that aren't available in open-mode, at least not without experimentalInteractiveRunEvents: true. However, this experimental flag broke some time ago, ref. cypress-io/cypress#18955, cypress-io/cypress#26634. There's unfortunately little indication that these issues will be fixed and meanwhile reports will not be available in open / interactive mode.

I get cypress_esbuild_preprocessor_1.createBundler is not a function

This can happen if you have a TypeScript Cypress configuration (IE. cypress.config.ts as opposed to cypress.config.js) similar to one of our examples and have a tsconfig.json without { "compilerOptions": { "esModuleInterop": true } }.

If you're really adamant about not using esModuleInterop: true, you can change

import createBundler from "@bahmutov/cypress-esbuild-preprocessor";

.. to

import * as createBundler from "@bahmutov/cypress-esbuild-preprocessor";

However, I recommend just using esModuleInterop: true if you don't fully understand the implications of disabling it.

I get cypress_esbuild_preprocessor_1.default is not a function

See answer above.

I get Cannot find module '@badeball/cypress-cucumber-preprocessor/esbuild'

Set compilerOptions.moduleResolution to node16 in your tsconfig.json. Users that are unable to upgrade moduleResolution to node16, can use the paths property as a workaround, like shown below.

{
  "compilerOptions": {
    "paths": {
      "@badeball/cypress-cucumber-preprocessor/*": ["./node_modules/@badeball/cypress-cucumber-preprocessor/dist/subpath-entrypoints/*"]
    }
  }
}

My JSON report isn't generated in run mode

You may have stumbled upon a configuration caveat (see docs/configuration.md: Caveats / Debugging) or are overriding some of the plugin's own event handlers (see docs/event-handlers.md: On event handlers).

I get Unexpected state in <state-handler>: <state>

You might be overriding some of the plugin's own event handlers (see docs/event-handlers.md: On event handlers).

I get Webpack Compilation Error (shown below)

Error: Webpack Compilation Error
Module parse failed: Unexpected token (2:21)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

This virtually always means that you have misconfigured @cypress/webpack-preprocessor. Here's an example of the crucial configuration value, for which when missing generates the error above.

This is usually seen when users are diverging from the examples by EG. placing preprocessor configuration in cypress/plugins/index.js (which some blog posts reference despite this being deprecated) or by placing webpack-specific content in webpack.config.js (or similar) and not referencing this file in cypress.config.js.

Why is cypress-tags missing?

The cypress-tags executable has been removed and made redundant. Specs containing no matching scenarios are automatically filtered, provided that filterSpecs is set to true.

Function members And(..) and But(..) are missing

These have been deprecated to reflect cucumber-js' behavior. You can still however use the And keyword in .feature files. As explained on SO,

And is only used in scenarios, not as step definition methods. Semantically it means "same keyword as in previous step"; technically it is just another step. In fact, you can use Given(), When() and Then() interchangeably in your step definitions, Cucumber will not enforce a match between the step keyword and the step definition function.

Which preprocessor version should I choose?

The observant reader might have noticed that there's a NPM package named cypress-cucumber-preprocessor and @badeball/cypress-cucumber-preprocessor. This is merely a result of maintainer and ownership transfer. The package cypress-cucumber-preprocessor is severely outdated by now and as far as I (the current maintainer) knows, there's no reason to be using it.

In any case, chose one over the other and don't attempt to mix these, essentially different packages, in the same project.