You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: adding exclude env var for compatibility with Cypress 10
* feat: adding exclude env var for compatibility with cypress v10
* moving webpack processor to deps
* chore: updating examples for new and legacy cypress config
* chore: renaming examples folder to test-apps and updating refs
* chore: ability to publish dev branch
* update cypress package
* update brand
* updating cypress to bust circle cache
* ensuring deps install in main test
Copy file name to clipboardexpand all lines: README.md
+32-19
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ This plugin **DOES NOT** instrument your code. You have to instrument it yoursel
40
40
}
41
41
```
42
42
43
-
Please see the [Examples](#examples) section down below, you can probably find a linked project matching your situation to see how to instrument your application's source code before running end-to-end tests to get the code coverage.
43
+
Please see the [Test Apps](#test-apps) section down below, you can probably find a linked project matching your situation to see how to instrument your application's source code before running end-to-end tests to get the code coverage.
44
44
45
45
If your application has been instrumented correctly, then you should see additional counters and instructions in the application's JavaScript resources, like the image down below shows.
46
46
@@ -66,7 +66,7 @@ That should be it! You should see messages from this plugin in the Cypress Comma
66
66
67
67
### App vs unit tests
68
68
69
-
You need to instrument your web application. This means that when the test does `cy.visit('localhost:3000')` any code the `index.html` requests should be instrumented by YOU. See [Examples](#examples) section for advice, usually you need to stick `babel-plugin-istanbul` into your pipeline somewhere.
69
+
You need to instrument your web application. This means that when the test does `cy.visit('localhost:3000')` any code the `index.html` requests should be instrumented by YOU. See [Test Apps](#test-apps) section for advice, usually you need to stick `babel-plugin-istanbul` into your pipeline somewhere.
70
70
71
71
If you are testing individual functions from your application code by importing them directly into Cypress spec files, this is called "unit tests" and Cypress can instrument this scenario for you. See [Instrument unit tests](#instrument-unit-tests) section.
Now the code coverage from spec files will be combined with end-to-end coverage.
138
138
139
-
Find example of a just the unit tests and JavaScript source files with collected code coverage in [examples/unit-tests-js](./examples/unit-tests-js).
139
+
Find example of a just the unit tests and JavaScript source files with collected code coverage in [test-apps/new-cypress-config/unit-tests-js](./test-apps/new-cypress-config/unit-tests-js).
Example in [examples/backend](examples/backend) folder.
158
+
Example in [test-apps/new-cypress-config/backend](test-apps/backend) folder.
159
159
160
160
You can also instrument your server-side code and produce combined coverage report that covers both the backend and frontend code
161
161
@@ -275,7 +275,7 @@ Sometimes NYC tool might be installed in a different folder not in the current o
275
275
276
276
TypeScript source files should be automatically included in the report, if they are instrumented.
277
277
278
-
See [examples/ts-example](examples/ts-example), [bahmutov/cra-ts-code-coverage-example](https://github.com/bahmutov/cra-ts-code-coverage-example) or [bahmutov/cypress-angular-coverage-example](https://github.com/bahmutov/cypress-angular-coverage-example).
278
+
See [test-apps/new-cypress-config/ts-example](test-apps/ts-example), [bahmutov/cra-ts-code-coverage-example](https://github.com/bahmutov/cra-ts-code-coverage-example) or [bahmutov/cypress-angular-coverage-example](https://github.com/bahmutov/cypress-angular-coverage-example).
279
279
280
280
## Include code
281
281
@@ -292,7 +292,7 @@ For example, if you want to make sure the final report includes all JS files fro
292
292
}
293
293
```
294
294
295
-
See example [examples/all-files](./examples/all-files)
295
+
See example [test-app/all-files](./test-apps/new-cypress-config/all-files)
296
296
297
297
## Exclude code
298
298
@@ -335,7 +335,20 @@ switch (foo) {
335
335
336
336
### Exclude files and folders
337
337
338
-
See [`nyc` configuration](https://github.com/istanbuljs/nyc#common-configuration-options) and [ include and exclude options](https://github.com/istanbuljs/nyc#using-include-and-exclude-arrays). You can include and exclude files using `minimatch` patterns in `.nycrc` file or using "nyc" object inside your `package.json` file.
338
+
The code coverage plugin will automatically exclude any test/spec files you have defined in `testFiles` (Cypress < v10) or `specPattern` (Cypress >= v10) configuration options. Additionaly, you can set the `exclude` pattern glob in the code coverage environment variable to specify additional files to be excluded:
339
+
340
+
```javascript
341
+
// cypress.config.js or cypress.json
342
+
env: {
343
+
codeCoverage: {
344
+
exclude: ['cypress/**/*.*'],
345
+
},
346
+
},
347
+
```
348
+
349
+
Cypress 10 and later users should set the `exclude` option to exclude any items from the `cypress` folder they don't want to be included in the coverage reports.
350
+
351
+
Additionaly, you can use [`nyc` configuration](https://github.com/istanbuljs/nyc#common-configuration-options) and [include and exclude options](https://github.com/istanbuljs/nyc#using-include-and-exclude-arrays). You can include and exclude files using `minimatch` patterns in `.nycrc` file or using "nyc" object inside your `package.json` file.
339
352
340
353
For example, if you want to only include files in the `app` folder, but exclude `app/util.js` file, you can set in your `package.json`
341
354
@@ -350,7 +363,7 @@ For example, if you want to only include files in the `app` folder, but exclude
350
363
351
364
**Note:** if you have `all: true` NYC option set, this plugin will check the produced `.nyc_output/out.json` before generating the final report. If the `out.json` file does not have information for some files that should be there according to `include` list, then an empty placeholder will be included, see [PR 208](https://github.com/cypress-io/code-coverage/pull/208).
352
365
353
-
Another important option is `excludeAfterRemap`. By default it is false, which might let excluded files through. If you are excluding the files, and the instrumenter does not respect the `nyc.exclude` setting, then add `excludeAfterRemap: true` to tell `nyc report` to exclude files. See [examples/exclude-files](examples/exclude-files).
366
+
Another important option is `excludeAfterRemap`. By default it is false, which might let excluded files through. If you are excluding the files, and the instrumenter does not respect the `nyc.exclude` setting, then add `excludeAfterRemap: true` to tell `nyc report` to exclude files. See [test-apps/exclude-files](test-apps/new-cypress-config/exclude-files).
354
367
355
368
## Disable plugin
356
369
@@ -392,19 +405,19 @@ npm run dev:no:coverage
392
405
393
406
## Examples
394
407
395
-
### Internal examples
408
+
### Internal test apps
396
409
397
410
Full examples we use for testing in this repository:
398
411
399
-
-[examples/backend](examples/backend) only instruments the backend Node server and saves the coverage report
400
-
-[examples/fullstack](examples/fullstack) instruments and merges backend, e2e and unit test coverage into a single report
401
-
-[examples/before-all-visit](examples/before-all-visit) checks if code coverage works when `cy.visit` is made once in the `before` hook
402
-
-[examples/before-each-visit](examples/before-each-visit) checks if code coverage correctly keeps track of code when doing `cy.visit` before each test
403
-
-[examples/one-spec.js](examples/one-spec.js) confirms that coverage is collected and filtered correctly if the user only executes a single Cypress test
404
-
-[examples/ts-example](examples/ts-example) uses Babel + Parcel to instrument and serve TypeScript file
405
-
-[examples/use-webpack](examples/use-webpack) shows Webpack build with source maps and Babel
406
-
-[examples/unit-tests-js](examples/unit-tests-js) runs just the unit tests and reports code coverage (JavaScript source code)
407
-
-[examples/unit-tests-ts](examples/unit-tests-ts)**NOT WORKING** runs just the unit tests and reports code coverage (TypeScript source code)
412
+
-[test-apps/backend](test-apps/new-cypress-config/backend) only instruments the backend Node server and saves the coverage report
413
+
-[test-apps/fullstack](test-apps/new-cypress-config/fullstack) instruments and merges backend, e2e and unit test coverage into a single report
414
+
-[test-apps/before-all-visit](test-apps/new-cypress-config/before-all-visit) checks if code coverage works when `cy.visit` is made once in the `before` hook
415
+
-[test-apps/before-each-visit](test-apps/new-cypress-config/before-each-visit) checks if code coverage correctly keeps track of code when doing `cy.visit` before each test
416
+
-[test-apps/one-spec.js](test-apps/new-cypress-config/one-spec.js) confirms that coverage is collected and filtered correctly if the user only executes a single Cypress test
417
+
-[test-apps/ts-example](test-apps/new-cypress-config/ts-example) uses Babel + Parcel to instrument and serve TypeScript file
418
+
-[test-apps/use-webpack](test-apps/new-cypress-config/use-webpack) shows Webpack build with source maps and Babel
419
+
-[test-apps/unit-tests-js](test-apps/new-cypress-config/unit-tests-js) runs just the unit tests and reports code coverage (JavaScript source code)
420
+
-[test-apps/unit-tests-ts](test-apps/new-cypress-config/unit-tests-ts)**NOT WORKING** runs just the unit tests and reports code coverage (TypeScript source code)
0 commit comments