-
Notifications
You must be signed in to change notification settings - Fork 111
Error: Code coverage tasks not registered by the plugins file #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “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? Sign in to your account
Comments
Check this: #331 |
I tried the solution mentioned there i.e In this case when I see in cypress configuration on the browser there is Also weirdly if I remove envConfig then i see coverage working but obviously I cannot run tests without env variables. This is how the plugin/index.js is. Is there anything wrong with the below code? const _ = require('lodash');
const env = require('/e2e-core/plugins/setEnv');
const corePlugin = require('/e2e-core/plugins');
module.exports = function plugins(on, config) {
const webpack = corePlugin(on, config);
const codeCoverage = require('@cypress/code-coverage/task')(on, config);
const envConfig = env(on, require('dotenv').config({ path: `${process.cwd()}/cypress/.env` }));
return _.merge({}, webpack, envConfig, codeCoverage);
};
|
Hmmm this is how my module.exports = async (on, config) => {
require('@cypress/code-coverage/task')(on, config)
const file = config.env.configFile || 'dev'
const envConfig = await getConfigurationByFile(file)
const allConfig = merge({}, config, envConfig)
return allConfig
} This is my async function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve('cypress/config', `cypress.${file}.json`)
return await fs.readJson(pathToConfigFile)
} hope it helps! |
I tried many things still have no idea. cy.log(`env:${Cypress.env('codeCoverageTasksRegistered')}`);. --> this is true but still not working I think it is related to the way we are env variables const envConfig = env(on, require('dotenv').config({ path: `${process.cwd()}/cypress/.env` })); in env its like below module.exports = (on, config) => {
config.env = process.env;
return config;
}; we have a lot of variables in .env. |
Did anyone manage to make any headway here? Having the exact same issues. 🙏 |
In our case, the problem was that we were doing require('@cypress/code-coverage/task')(on, config)
config.env = {
...process.env,
...config.env,
} |
This is exactly what I tried but it still tells me that the tasks weren't registered. If I log out the config, I can clearly see that |
Any updates on this? |
add |
In my case, Cypress version 10.3.1, the I could testify this by putting a |
+1 to @jourdanrodrigues I was debugging this for ages and ended up forking this repo and throwing errors every-which-way to find out why it wasn't working. I eventually found that the tasks weren't registered and "to fix this in config's I made the following changes to fix this:
module.exports = {
e2e: {
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config);
return config;
},
},
env: {
codeCoverageTasksRegistered: true,
},
}; |
Thanks! I don't know why exactly, but this worked nicely for me. It seems that |
You should have a loohk on this official configuration file. It helped me a lot 😉 https://github.com/cypress-io/cypress-realworld-app/blob/develop/cypress.config.ts#L89 |
Uh oh!
There was an error while loading. Please reload this page.
Code-coverge debug logs:
code-coverage combined NYC options { 'report-dir': './coverage', reporter: [ 'lcov', 'clover', 'json', 'json-summary' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: false } +0ms
thats it and nothing else
Added in support --> index.js
In plugin index.js -->
Always get below error

tried adding this
in e2e-core/plugins as well then it says
Versions
Cypress 6.5.0
mac os catalina
Node v15.8.0
NPM v7.5.3
Instrumentation: istanbul
React application
Code-coverage: 3.9.2
webpack-preprocessor: 5.6.0
cucumber-preprocessor: 4.0.1
Shell: xsh
We have e2e tests as feature files.
Cypress is in the root where as application is as packages.
We also have e2e-core package for cypress where there is also a common plugins file loaded onto cypress folder plugins-->index.js.
webpack.config.js
webpack index.js
Instrumentation is setup. window.coverage works

Is there

.nyc_output
folder? Is there.nyc_output/out.json
file. Is it empty? Can you paste at least part of it so we can see the keys and file paths?no folder created
Do you have any custom NYC settings in
package.json
(nyc
object) or in other NYC config filesno
Do you run Cypress tests in a Docker container?
not in this case
Link to the repo
Not a public repo.
The text was updated successfully, but these errors were encountered: