code-coverage: Doesn't work with non-root project folder on Windows

First of all, really awesome initiative with this plugin.

My cypress test suite is inside a test folder. With this plugin, my specs fail with the following message:

CypressError: cy.task('coverageReport') failed with the following error:

> Error: Command failed: nyc report --reporter=html
    at makeError (/Users/xxx/projectname/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/Users/xxx/projectname/node_modules/execa/index.js:278:16)
    at <anonymous>

Moving the cypress folder and cypress.json to the root of the project, outside of /test, makes the whole thing work again.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 18 (6 by maintainers)

Most upvoted comments

I’ve the same issue, but I can’t fix it like @ericorruption suggested, because my client (gui) and server (backend) are seperate repositories and there is currently no way into merging them.

The error I get in the after all section:

CypressError: cy.task('coverageReport') failed with the following error:

> Error: spawn nyc ENOENT
    at notFoundError (C:\Users\xxx\projectname\gui\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\xxx\projectname\gui\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\xxx\projectname\gui\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

Because this error occurred during a 'after all' hook we are skipping all of the remaining tests.

My guess is that nyc gets executed in the folder where cypress.json resides and therfore hasn’t direct access to the source files. Running the nyc report command in a shell doesn’t fail, but ignores the missing source files, so I don’t know if that is really the problem…

A little off-topic: The last line in the error message is a little missleading. It looks like it is a generic error for all hooks (before, beforeEach, afterEach, after), but it doesn’t make much sense that after the after hook the remaining tests are skipped, because there never won’t be any tests remaining.

Hmm @jrnail23 this seems like a separate issue from the original (nyc location). Please open a new issue with folder structure described in enough detail so I can understand it - or better a public repo available that shows the problem

EDIT: in my case, nyc had been accidentally removed, so this can be a cause - it actually wasn’t there 😃

The same issue happens with yarn workspaces, where nyc is installed in a higher folder.

This is on Mac OS X