code-coverage
code-coverage copied to clipboard
Dependency Error
Error: Can't walk dependency graph: Cannot find module '../self-coverage-helper' from 'C:\repo\myproject\node_modules\nyc'
nyc is installed - package.json: "nyc": "15.1.0",
Oops...we found an error preparing this test file:
C:\repo\myproject\cypress\support\index.js
I'm getting the same error:
Oops...we found an error preparing this test file:
/home/slaweet/git/telltale-vue/cypress/support/index.js
The error was:
Error: Cannot find module '@vue/babel-preset-app' from '/home/slaweet/git/telltale-vue' while parsing file: /home/slaweet/git/telltale-vue/cypress/support/index.js
installed versions (based on yarn.lock
):
"@cypress/[email protected]":
version "3.8.1"
resolved "https://registry.yarnpkg.com/@cypress/code-coverage/-/code-coverage-3.8.1.tgz#913f34b1063423cc881988fa3b452da170aea5b6"
integrity sha512-XkecqM/4xHZdAPUMOxOUi5yf2TDWUycqIi6Z6zdGiO9j04CxkRoVTOJYsE14i7uG7orudYSLcLFJEeJv237qXQ==
dependencies:
"@cypress/browserify-preprocessor" "3.0.0"
debug "4.1.1"
execa "4.0.2"
globby "11.0.0"
istanbul-lib-coverage "3.0.0"
js-yaml "3.14.0"
nyc "15.1.0"
I also saw someone else asking about it on SO: https://stackoverflow.com/questions/63703320/cypress-code-coverage-cant-resolve-self-coverage-helper-cypress
I have the same issue and the "fix" given on SO doesn't apply to my use case... Did someone of you find another solution?
If you're getting this error, a possible cause is that you've mixed up the Cypress plugins and support config files.
This issue was the first result for my cypress "can't walk dependency graph"
google query. Posting my findings here in case if they could help to someone.
In my case the error was caused by the fact that one of the integration test directories was a symlink. My structure of cypress directory:
node_modules
integration
some-normal-dir
the-symlinked-dir
...
...
When browserify tried to process files from the symlinked directory, it was not aware of node_modules
directory.
The solution was (plugins.js
):
const path = require('path');
const cucumber = require('cypress-cucumber-preprocessor').default;
const browserify = require('@cypress/browserify-preprocessor');
module.exports = (on, config) => {
const options = {
...browserify.defaultOptions,
browserifyOptions: {
...browserify.defaultOptions.browserifyOptions,
paths: [
// In case if some of the integration tests are symlinked, let
// browserify know the node_modules location.
path.join(__dirname, '/path/to/node_modules'),
],
}
};
on('file:preprocessor', cucumber(options));
};
(Fun thing: I was getting the dependency graph error locally on Mac and Ubuntu, but there was no error in GitHub Actions 🤷)
Weird, but I am not sure how to fix this without a reproducible example
Had this same error with another module (cypress-axe). Upgrading cypress to the latest vesion (i was on 4.x, went to 6.x) fixed the issue.
I have the same issue. @Leksat were you able to resolve it?
My Issue resolved by using the command npm install
If you're getting this error, a possible cause is that you've mixed up the Cypress plugins and support config files.
@slikts
I can confirm that you had it right in my case, once I moved the plugins init to a single file, it worked