Skip to content

Commit d980db8

Browse files
fix(cypress): do not override coverage exclude (#304)
1 parent 6b8a66d commit d980db8

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

packages/e2e-cypress/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,26 @@ To generate reports, run `test:e2e:ci` and/or `test:component:ci` scripts.
5757
Running them both sequentially within the same command (eg. `yarn test:e2e:ci && yarn test:component:ci`) will result in combined coverage report.
5858
You'll find the generated report into `coverage/lcov-report` folder.
5959

60-
We provide a [preset configuration](https://github.com/quasarframework/quasar-testing/blob/dev/packages/e2e-cypress/nyc-config-preset.json) for the coverage report which:
60+
We provide a [preset configuration][nyc-config-preset] for the coverage report which:
6161

6262
- enables `all` option to include some files which are ignored by default:
6363
- dynamically imported components, such as layout and pages imported by vue-router;
6464
- files not touched by any test.
6565
- excludes test folders (`__tests__`) and TS declaration files (\*.d.ts), which should already be excluded [by default](https://github.com/istanbuljs/schema/blob/master/default-exclude.js) but apparently aren't;
66-
- only includes actual code files, leaving out code-like static assets (eg. svgs).
66+
- only includes actual code files, leaving out code-like static assets (e.g. SVGs).
6767

6868
Check out [nyc official documentation](https://github.com/istanbuljs/nyc) if you want to customize report generation.
6969
You can either add options into `.nycrc` file or generate reports on the fly running `nyc report <options>`.
7070

71+
If you want to override the options that are defined by our [preset configuration][nyc-config-preset](_or any preset_), you should be aware of [this nyc issue](https://github.com/istanbuljs/nyc/issues/1286).
72+
You can either apply [this workaround](https://github.com/istanbuljs/nyc/issues/1286#issuecomment-926077635) or embed our [preset configuration][nyc-config-preset] into your `.nycrc` file directly, instead of `extends`.
73+
7174
> Note that we do not setup [Istanbul TS configuration](https://github.com/istanbuljs/istanbuljs/tree/master/packages/nyc-config-typescript) and its dependencies as Cypress claims [it's able to manage TS code coverage out-of-the-box](https://github.com/cypress-io/code-coverage#typescript-users).
7275
> Some TS files may be excluded by the report in scenarios, eg. if they aren't actually imported (dead code), if they're tree-shaked away by a bundler or if they only contain types/interfaces, and as such have no actual JS representation.
7376
> Please open an issue if you notice some files are missing from generated reports in this scenario.
7477
78+
[nyc-config-preset]: https://github.com/quasarframework/quasar-testing/blob/dev/packages/e2e-cypress/nyc-config-preset.json
79+
7580
### Upgrade from Cypress AE v4
7681

7782
> if you're coming from v3, follow [the migration guide for v4 and v4.1 first](https://github.com/quasarframework/quasar-testing/tree/cypress-v4/packages/e2e-cypress#upgrade-from-cypress-v4-to-v41-optional)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"all": true,
3-
"include": ["**/*.{js,cjs,mjs,jsx,ts,tsx,vue}"],
4-
"exclude": ["**/__tests__/**", "**.d.ts"]
3+
"include": ["src/**/*.{js,cjs,mjs,jsx,ts,tsx,vue}"],
4+
"exclude": ["**/__tests__/**", "**/*.d.ts"]
55
}

packages/e2e-cypress/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"lodash": "^4.17.21",
3737
"nyc": "^15.1.0",
3838
"start-server-and-test": "^1.14.0",
39-
"vite-plugin-istanbul": "^3.0.2"
39+
"vite-plugin-istanbul": "^3.0.3"
4040
},
4141
"devDependencies": {
4242
"@types/lodash": "^4.14.182",

packages/e2e-cypress/src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ module.exports = async function (api) {
3434
api.extendViteConf((viteConf) => {
3535
viteConf.plugins.push(
3636
istanbul({
37-
exclude: ['.quasar/*'],
38-
forceBuildInstrument: api.ctx.prod ? true : false,
37+
forceBuildInstrument: api.ctx.prod,
3938
}),
4039
);
4140
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10437,10 +10437,10 @@ vite-jsconfig-paths@^2.0.1:
1043710437
recrawl-sync "^2.0.3"
1043810438
tsconfig-paths "^3.9.0"
1043910439

10440-
vite-plugin-istanbul@^3.0.2:
10441-
version "3.0.2"
10442-
resolved "https://registry.yarnpkg.com/vite-plugin-istanbul/-/vite-plugin-istanbul-3.0.2.tgz#abb01b337bbd3a20666d9d82d472688a99ba2796"
10443-
integrity sha512-eOKedaeciqJTLEAUo7mkMqXjjeAXGhHUYuiLLBUaBwj8AdO31uVOsZvKeVViRqHKyhi5YlarmGh8r7jJVlX0VQ==
10440+
vite-plugin-istanbul@^3.0.3:
10441+
version "3.0.3"
10442+
resolved "https://registry.yarnpkg.com/vite-plugin-istanbul/-/vite-plugin-istanbul-3.0.3.tgz#88a0e286ccc33030b36d7809a78382cf84dd5f74"
10443+
integrity sha512-2nCYSsY1kgF83S007rg0GPmeL5P+bph8Z5RJ3Pv1kHHx9OMyKt/cLyGCWAYQnBk9VckzXRGEaX3FSLtcSai4Yg==
1044410444
dependencies:
1044510445
"@istanbuljs/load-nyc-config" "^1.1.0"
1044610446
istanbul-lib-instrument "^5.1.0"

0 commit comments

Comments
 (0)