-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress Code Coverage cypress.config.ts file - setupNodeEvents(on, config) error required is not defined #715
Comments
I did npm install -D @cypress/code-coverage and import '@cypress/code-coverage/support'
in cypress/support/e2e.js
my cypress.config.ts looks like this
import { defineConfig } from "cypress";
export default defineConfig({
projectId: '...'
viewportWidth: 1500,
viewportHeight: 1500,
video: false,
screenshotOnRunFailure: false,
e2e: {
setupNodeEvents(on, config) {
require("@cypress/code-coverage/task")(on, config)
return config;
},
baseUrl: "https://localhost:5173/",
},
}); |
I had the same problem,I desperately need a solution! help! help! help! help! |
I still couldn't figure out where is the problem... |
if you look in the function export default function registerCodeCoverageTasks(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions,
): void; try component: {
setupNodeEvents(on, config) {
coverageTask(on, config);
return config;
},
``` |
@sandram92 Has this been resolved? |
The Would have found this a lot sooner if it was on https://docs.cypress.io/guides/tooling/code-coverage#E2E-code-coverage |
This solution worked. |
This doesn't work for me (using React), I get:
If I try
Then it works, but TypeScript complains
|
I wanted to set up cypress code coverage on my sveltekit but I get an error in my cypress.config.ts file -
and when I run cypress test I get error :Your configFile threw an error from: C:\Code\me-ui\cypress.config.ts
The error was thrown while executing your e2e.setupNodeEvents() function:
ReferenceError: require is not defined
at setupNodeEvents (file:///C:/Code/me-ui/cypress.config.ts:10:13)
Anyone experienced this before?
The text was updated successfully, but these errors were encountered: