In the cypress.config.js , I'm trying to register tasks / plug in events and set my env configuration exactly as documented on their guide.
However, when trying to use "on" inside setupNodeEvents I'm getting the error in the title about needing to register it.
Also, to note when passing both arguments (on, config), the config file does not pick up the env variable. Only when I put config first or config by itself, do the env variables pass.
Also, my tasks are properly coded inside the test classes. I know this because they work just fine for previous versions of cypress 9 but I can share them if someone thinks that's where the
/// <reference types="cypress" />
const { defineConfig } = require('cypress');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on,config) {
if (config.env == undefined) {
return {
baseUrl: "intentionally blank",
env: {
env: "test",
schedulerBaseUrl: "intentionally blank",
signInUrl: "intentionally blank",
enableAccessibility: true,
takeScreenShot: false,
suites: "",
},
};
}
else if (config.env == 'development') {
return {
baseUrl: "https://blank.blank.com:blank",
env: {
environment: "development",
schedulerBaseUrl: "intentionally blank",
signInUrl: "intentionally blank",
enableAccessibility: false,
takeScreenShot: false
},
}
}
on('task', {
log(message) {
console.log(message)
return null
},
table(message) {
console.table(message)
return null
}
})
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
launchOptions.args.push('--disable-gpu');
launchOptions.args.push('--disable-dev-shm-usage');
launchOptions.args.push('use-fake-device-for-media-stream');
return launchOptions;
}
});
},
chromeWebSecurity: false,
screenshotOnRunFailure: false,
trashAssetsBeforeRuns: true,
numTestsKeptInMemory: 0,
video: true,
videoCompression: false,
enableAccessibility: false,
takeScreenShot: false,
defaultCommandTimeout: 10000,
execTimeout: 500000,
pageLoadTimeout: 500000,
retries: {
runMode: 1,
openMode: 0
},
blockHosts: [
"*intentionally blank"
],
redirectionLimit: 199,
projectId: "intentionally blank",
}
})
require('@applitools/eyes-cypress')(module);