-
Notifications
You must be signed in to change notification settings - Fork 110
Doesn't work with non-root project folder on Windows #18
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? No Sign in to your account
Comments
I've the same issue, but I can't fix it like @ericorruption suggested, because my client ( The error I get in the
My guess is that 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 ( |
Looks like my error wasn't the same as from @ericorruption. The problem was that on('task', {
coverageReport() {
let commonParentDir = process.cwd();
const rawCoverageDir = path.join(process.cwd(), '.nyc_output');
const nycOutput = require(path.join(rawCoverageDir, 'out.json'));
const allFiles = Object.keys(nycOutput);
for (const file of allFiles) {
let p = path.relative(commonParentDir, file);
if (p.startsWith('..')) {
commonParentDir = path.join(commonParentDir, p.match(/^(\.\.[\/\\])+/)[0] + '.');
}
}
let nycOptions = require(path.join(process.cwd(), 'package.json')) || {};
nycOptions = nycOptions.nyc;
const reportDir = path.join(process.cwd(), nycOptions['report-dir'] || './coverage')
const reporter = nycOptions['reporter'] || ['lcov', 'clover', 'json']
const reporters = Array.isArray(reporter)
? reporter.map(name => `--reporter=${name}`)
: `--reporter=${reporter}`
let command = path.join(process.cwd(), 'node_modules', '.bin', 'nyc');
const args = ['report', '--cwd', commonParentDir, '-t', rawCoverageDir, '--report-dir', reportDir].concat(reporters).map((arg) => arg.replace(/ /g, '\\ '));
command = command + ' ' + args.join(' ');
// console.log(`executing command for coverageReport: ${command}`);
return new Promise((resolve, reject) => {
exec(command, (err, stdout, stderr) => {
if (err) reject(err);
resolve({stdout, stderr});
});
});
}
}); It should use the topmost folder as working directory so that all files referenced by As Maybe this also fixes @ericorruption's issue? If so, I can make a PR with this change. If not, how does your folder structure look like? Where resides the folder
|
I've got a similar problem, where I've got more than one cypress test suite that need to run separately (integration tests, post-deploy smoke tests, etc.), and my integration tests (and cypress.json file) are at I also have the following in my "nyc": {
"report-dir": "./coverage/cypress"
} When I run them, the I also tried adding |
Just a suggestion to better deal with the issue of multiple cypress projects and/or those which have |
@ericorruption can you try plugin v1.10.1 with your situation? I think I have recreated it in bahmutov/cy-nested-code-coverage#1 For other issues, where it cannot find |
It can't find To reproduce, (not tested, but I think it should behave the same) clone your repo cypress-io/cypress-example-todomvc-redux on a Windows PC and make sure that |
@schl3ck since I don't have access to a Windows machine, I wonder why So, since I never install tools globally (bad practice), can I ask something: When you clone and install cypress-io/cypress-example-todomvc-redux on Windows, then |
@bahmutov Yes, that's right (I had to install npx seperatly, because I use node v6). I've not tested it now, because I need node v6 for my work (the example needs node v12) and on Windows there is not an official |
I have the same error on Mac OS. But yesterday the code was working. I think it might be connected with my tests in /integration-tests/<cypress_folders path |
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 |
Just dropping by to bump this issue again, as I'm finally having to deal with it again #18 (comment). It would be great if the plugin allowed for configurable folder structures and config locations, etc. |
Can you try using version https://github.com/cypress-io/code-coverage/releases/tag/v1.14.0 of this plugin - it now should discover |
it's not that it can't find nyc, it's that when your cypress.json is in a nested location, the working directory ends up being that same nested location. The task file assumes your package.json file is in the working directory, so as a result, it can't find the package.json file (and thus ignores any configuration you've set in there). |
FYI, as a workaround, I've had to extract project-specific cypress config files in my project root (although I'd really prefer to have those co-located with their respective cypress projects), as I was previously using |
Hmm @jrnail23 this seems like a separate issue from the original ( |
Hi everyone, I have a beta release of Cypress that uses |
@bahmutov Worked for me! |
🎉 This issue has been resolved in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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:
Moving the
cypress
folder andcypress.json
to the root of the project, outside of/test
, makes the whole thing work again.The text was updated successfully, but these errors were encountered: