code-coverage icon indicating copy to clipboard operation
code-coverage copied to clipboard

Dependency Error

Open tobiasgrossmann opened this issue 4 years ago • 9 comments

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

tobiasgrossmann avatar Sep 02 '20 11:09 tobiasgrossmann

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

slaweet avatar Sep 22 '20 05:09 slaweet

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?

mguthmuller avatar Oct 26 '20 13:10 mguthmuller

If you're getting this error, a possible cause is that you've mixed up the Cypress plugins and support config files.

slikts avatar Nov 09 '20 08:11 slikts

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 🤷)

Leksat avatar Dec 21 '20 11:12 Leksat

Weird, but I am not sure how to fix this without a reproducible example

bahmutov avatar Dec 21 '20 18:12 bahmutov

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.

gtsop avatar Jan 14 '21 11:01 gtsop

I have the same issue. @Leksat were you able to resolve it?

Sayyara avatar Mar 17 '21 13:03 Sayyara

My Issue resolved by using the command npm install

priyanka87thakur avatar Apr 29 '21 13:04 priyanka87thakur

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

meir-rio avatar Oct 31 '21 10:10 meir-rio