Open samit4me opened 4 years ago
I think I've seen something similar before in jest. If you have a configuration with a unit test runner and a lint runner (like the one above), you need to specify collectCoverage
for both jest and the test runner for collectCoverage
to take effect. Giving you a config like the following:
module.exports = {
collectCoverage: true,
projects: [
{
displayName: 'test',
collectCoverage: true,
},
{
runner: 'jest-runner-eslint',
displayName: 'lint',
testMatch: ['<rootDir>/src/**/*.js'],
watchPlugins: ["jest-runner-eslint/watch-fix"],
},
],
};
Based on this, I suspect that the following should work to enable the watch plugin:
module.exports = {
watchPlugins: ["jest-runner-eslint/watch-fix"],
projects: [
{
displayName: 'test',
},
{
runner: 'jest-runner-eslint',
displayName: 'lint',
testMatch: ['<rootDir>/src/**/*.js'],
watchPlugins: ["jest-runner-eslint/watch-fix"],
},
],
};
Nice, I've just tried your solution and it works. Interestingly, it also work if you only specify the watchPlugins
once outside of projects
, for example:
module.exports = {
watchPlugins: ["jest-runner-eslint/watch-fix"],
projects: [
{
displayName: 'test',
},
{
runner: 'jest-runner-eslint',
displayName: 'lint',
testMatch: ['<rootDir>/src/**/*.js'],
},
],
};
I believe this is due to the distinction between global config and project config. Properties that come from the global config are only valid at the top level, whereas properties from the project config are only valid at the project level. This isn't mentioned in the docs, but can be seen in the type definitions.
:heavy_check_mark: When using a basic jest config the
Press F to override ESLint --fix
works as expected.:heavy_multiplication_x: When using a projects configuration the
Press F to override ESLint --fix
does not work.