Skip to content

Commit 7a32564

Browse files
authored
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
1 parent acd756f commit 7a32564

File tree

385 files changed

+83197
-11930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

385 files changed

+83197
-11930
lines changed

.circleci/config.yml

+157-541
Large diffs are not rendered by default.

.gitignore

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
node_modules/
2-
cypress/videos
3-
cypress/screenshots
2+
**/cypress/videos
3+
**/cypress/screenshots
44
coverage/
55
.nyc_output/
66
dist/
77
.cache/
88
.vscode/
99
cypress-coverage/
10-
examples/*/cypress/videos
11-
examples/*/cypress/screenshots
1210
yarn.lock
11+
.parcel-cache

.releaserc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"branches": [
3+
"master",
4+
"next",
5+
{
6+
"name": "besta",
7+
"prerelease": true
8+
},
9+
{
10+
"name": "dev",
11+
"prerelease": true
12+
}
13+
]
14+
}

README.md

+32-19
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This plugin **DOES NOT** instrument your code. You have to instrument it yoursel
4040
}
4141
```
4242

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.
4444

4545
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.
4646

@@ -66,7 +66,7 @@ That should be it! You should see messages from this plugin in the Cypress Comma
6666

6767
### App vs unit tests
6868

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.
7070

7171
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.
7272

@@ -136,7 +136,7 @@ module.exports = (on, config) => {
136136

137137
Now the code coverage from spec files will be combined with end-to-end coverage.
138138

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).
140140

141141
### Alternative for unit tests
142142

@@ -155,7 +155,7 @@ module.exports = (on, config) => {
155155

156156
## Instrument backend code
157157

158-
Example in [examples/backend](examples/backend) folder.
158+
Example in [test-apps/new-cypress-config/backend](test-apps/backend) folder.
159159

160160
You can also instrument your server-side code and produce combined coverage report that covers both the backend and frontend code
161161

@@ -275,7 +275,7 @@ Sometimes NYC tool might be installed in a different folder not in the current o
275275

276276
TypeScript source files should be automatically included in the report, if they are instrumented.
277277

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).
279279

280280
## Include code
281281

@@ -292,7 +292,7 @@ For example, if you want to make sure the final report includes all JS files fro
292292
}
293293
```
294294

295-
See example [examples/all-files](./examples/all-files)
295+
See example [test-app/all-files](./test-apps/new-cypress-config/all-files)
296296

297297
## Exclude code
298298

@@ -335,7 +335,20 @@ switch (foo) {
335335

336336
### Exclude files and folders
337337

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.
339352

340353
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`
341354

@@ -350,7 +363,7 @@ For example, if you want to only include files in the `app` folder, but exclude
350363

351364
**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).
352365

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).
354367

355368
## Disable plugin
356369

@@ -392,19 +405,19 @@ npm run dev:no:coverage
392405

393406
## Examples
394407

395-
### Internal examples
408+
### Internal test apps
396409

397410
Full examples we use for testing in this repository:
398411

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)
408421

409422
### External examples
410423

@@ -459,7 +472,7 @@ module.exports = (on, config) => {
459472
}
460473
```
461474

462-
See [examples/use-plugins-and-support](examples/use-plugins-and-support)
475+
See [test-apps/use-plugins-and-support](test-apps/new-cypress-config/use-plugins-and-support)
463476

464477
## Debugging
465478

cypress/index.html

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
<body>
2-
<nav>
3-
<a href="/about.html">About</a>
4-
</nav>
52
<h2>Test page</h2>
6-
<p>Open the DevTools to see console messages</p>
7-
<script src="app.js"></script>
83
</body>

0 commit comments

Comments
 (0)