Upon following example in the repo /examples/simple-typescript started run of my cypress tests and following error was thrown
I think is due to the fact that I am using npm workspaces so all node_modules packages get hoisted into the root directory.
So projects is located in /projects/e2e, so i think the reporter is expected to be in that folder or a node modules in the folder. This is not the case.
If it were possible to specify the location of the module then that would be easier. There may be a config but I could not see it.
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
import createEsbuildPlugin from '@badeball/cypress-cucumber-preprocessor/esbuild';
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
import EnvironmentConfiguration from '../models/environmentConfig';
async function setupNodeEvents(
on: Cypress.PluginEvents,
config: Omit<Cypress.PluginConfigOptions, 'env'> & {
env: EnvironmentConfiguration;
}
): Promise<Cypress.PluginConfigOptions> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('cypress-mochawesome-reporter/plugin')(on);
// This is required for the preprocessor to be able to generate JSON reports after each run, and more,
await addCucumberPreprocessorPlugin(on, config);
on(
'before:browser:launch',
(
browser: Cypress.Browser,
browserLaunchOptions: Cypress.BrowserLaunchOptions
) => {
if (browser.name === 'electron') {
browserLaunchOptions.args.push('--remote-debugging-port=9222');
// whatever you return here becomes the new args
return browserLaunchOptions;
}
return browserLaunchOptions;
}
);
on(
'file:preprocessor',
createBundler({
define: {
// replaces every instance of "process.env.NODE_ENV" string
// in the spec with the string "development"
'process.env.NODE_ENV': '"development"'
},
plugins: [createEsbuildPlugin(config)]
})
// createBundler()
);
// Make sure to return the config object as it might have been modified by the plugin.
const baseUrl = config.env.baseUrl;
if (!baseUrl) {
throw new Error(
`missing 'baseUrl' environment variable please check terminal command`
);
}
return config;
}
export default setupNodeEvents;
Relevant log output
Error loading the reporter: cypress-mochawesome-reporter
We searched for the reporter in these paths:
- /home/node/app-workspace-esbuild/projects/e2e/cypress-mochawesome-reporter
- /home/node/app-workspace-esbuild/projects/e2e/node_modules/cypress-mochawesome-reporter
Learn more at https://on.cypress.io/reporters
Error: Cannot find module '/home/node/app-workspace-esbuild/projects/e2e/node_modules/cypress-mochawesome-reporter'
Require stack:
- /home/node/.cache/Cypress/12.14.0/Cypress/resources/app/packages/server/lib/reporter.js
at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
at n._resolveFilename (node:electron/js2c/browser_init:249:1105)
at PackherdModuleLoader._tryResolveFilename (evalmachine.<anonymous>:1:743978)
at PackherdModuleLoader._resolvePaths (evalmachine.<anonymous>:1:740799)
at PackherdModuleLoader.tryLoad (evalmachine.<anonymous>:1:738842)
at Function.<anonymous> (evalmachine.<anonymous>:1:749631)
at d._load (<embedded>:4588:29304)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at E.loadReporter (<embedded>:4593:19480)
at C.initializeReporter (<embedded>:4640:426060)
at C.startWebsockets (<embedded>:4640:426364)
at C.open (<embedded>:4640:424693)
at async v.create (<embedded>:4640:437103)
at async O (<embedded>:4640:513450)
at async H (<embedded>:4640:526407)
Environment
What happened?
Upon following example in the repo /examples/simple-typescript started run of my cypress tests and following error was thrown
I think is due to the fact that I am using npm workspaces so all node_modules packages get hoisted into the root directory.
So projects is located in /projects/e2e, so i think the reporter is expected to be in that folder or a node modules in the folder. This is not the case.
If it were possible to specify the location of the module then that would be easier. There may be a config but I could not see it.
Config file
Setup Node Events file too for reference
Relevant log output
Anything else?
Reference to NPM workspaces https://docs.npmjs.com/cli/v7/using-npm/workspaces