Skip to content

Commit

Permalink
update cypress coverage docs, remove temp "push:"
Browse files Browse the repository at this point in the history
  • Loading branch information
scytacki committed May 23, 2024
1 parent 6b5c7ab commit 5dfd78b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deployed-regresssion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
description: URL to test
default: https://collaborative-learning.concord.org/index-staging.html
required: true
# just to get this to be available for testing
push:
jobs:
all-tests:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions docs/cypress-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ The first step in the process is tracking which lines of code are hit. This is d
- look in the browser console for `window.__coverage__`
- this variable should contain info about each file that has been covered so far

This coverage information needs to be collected after each test run. This is done by the `@cypress/code-coverage/support` module that is imported in the `cypress/support/index.js` file. It sets up the coverage stats before each test, and then sends the coverage information to the cypress test runner via `cy.task`.
This coverage information needs to be collected after each test run. This is done by the `@cypress/code-coverage/support` module that is imported in the `cypress/support/e2e.js` file. It sets up the coverage stats before each test, and then sends the coverage information to the cypress test runner via `cy.task`.

The coverage information needs to be received by the cypress test runner and written out to a file. This is done by the plugin `@cypress/code-coverage/task`. It is added to the `cypress/plugins/index.js`. It receives the coverage information, merges it and saves it in the raw file `.nyc_output/out.json`. It also defines a task command which runs the nyc processor to convert this raw file into a set of html files.
The coverage information needs to be received by the cypress test runner and written out to a file. This is done by the plugin `@cypress/code-coverage/task`. It is added by `cypress.config.ts`. It receives the coverage information, merges it and saves it in the raw file `.nyc_output/out.json`. It also defines a task command which runs the nyc processor to convert this raw file into a set of html files.

By default the cypress coverage tasks are disabled so they don't slow down and clutter up the test log. You can open cypress with them enabled by using the `npm run test:coverage:cypress:open`. For reference, the default behavior is set in `cypress.jon` with the `"coverage": false` entry.
By default the cypress coverage tasks are disabled so they don't slow down and clutter up the test log. You can open cypress with them enabled by using the `npm run test:coverage:cypress:open`. For reference, the default behavior is set in `cypress.config.ts` with the `coverage: false` entry.

With the coverage tasks enabled, when running the cypress tests you should see extra 'task' events being logged. These are a record of the `support` module communicating with the `task` module.

Expand All @@ -28,4 +28,4 @@ The nyc processor is configured by the `nyc` section in `package.json`. It is co

This setup hasn't been tested to see if it covers cypress based unit tests. These work slightly differently because in this case the application code is imported right into the test runner code. So in this case the test runner needs to instrument this application code when it is loaded.

In theory the setup in this project should work in this case. This is because the `@cypress/webpack-preprocessor` is being used. This should pass all cypress test code through the same webpack config that is used by the webpack-dev-server. So the application code should get instrumented during this process by the `istanbul-instrumenter-loader`.
In theory the setup in this project should work in this case. This is because the `@cypress/webpack-preprocessor` is being used. This should pass all cypress test code through the same webpack config that is used by the webpack-dev-server. So the application code should get instrumented during this process by the `istanbul-instrumenter-loader`.

0 comments on commit 5dfd78b

Please sign in to comment.