Skip to content

Commit

Permalink
Merge pull request #8551 from cfpb/ans_cy_commands
Browse files Browse the repository at this point in the history
Update Cypress commands
  • Loading branch information
anselmbradford authored Sep 4, 2024
2 parents 9543f72 + f126993 commit 54812b0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Prepare config
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: ./test/cypress/run-specs.sh
run: ./scripts/cypress-fast-specs.sh

- name: Run Cypress
uses: cypress-io/github-action@v6
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for more information.

#### Browser Testing

We run automated browser tests in headless Chrome with `yarn cypress run`.
We run automated browser tests in headless Chrome with `yarn cy`.
See our [cross browser testing docs](https://cfpb.github.io/consumerfinance.gov/other-front-end-testing/#cross-browser-testing) for other testing methods.

#### Satellite app assets
Expand Down
8 changes: 6 additions & 2 deletions docs/functional-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ We have included Cypress as a dependency of this project. The only installation

### Cypress app

To run the desktop Cypress app execute `yarn cypress open` from the command line. From the app, you can select the tests you want to run and the browser you want to run them in.
To run the desktop Cypress app execute `yarn cy open` from the command line. From the app, you can select the tests you want to run and the browser you want to run them in.

### Command line

You can run functional tests from the command line with `yarn cypress run`. That will run all tests in the `test/cypress/integration/` directory with the default test configuration: headless, in Cypress's default Electron browser, and against `localhost:8000`. You might want to modify the test run with some common arguments:
You can run functional tests from the command line with `yarn cy`. That will run all tests in the `test/cypress/integration/` directory with the default test configuration: headless, in Cypress's default Electron browser, and against `localhost:8000`.

To run Cypress only on changed specs, run `yarn cy fast`.

For a customized Cypress run, you might want to call Cypress directly with `npx cypress run` and pass in some common arguments:

- `--spec test/cypress/integration/{path/to/test.js}` runs a single test suite
- `--browser chrome` runs the tests in Chrome, which is what we use to run tests in our continuous integration pipeline
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
"scripts": "yarn build scripts",
"watch": "yarn build watch",
"build": "node ./esbuild/build.js",
"cypress": "./node_modules/.bin/cypress run --config-file cypress.template.mjs",
"open": "./node_modules/.bin/cypress open --config-file cypress.template.mjs",
"fast-cypress": "./test/cypress/run-specs.sh && ./node_modules/.bin/cypress run"
"cy": "./scripts/cypress.sh"
},
"prettier": {
"singleQuote": true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Used by `yarn cy fast` command.
echo -n "${CHANGED_FILES:-$(git --no-pager diff --name-only origin/main)}" \
| sed 's/___/\n/g' \
| node "$(git rev-parse --show-toplevel)/test/cypress/spec-map.js"
9 changes: 9 additions & 0 deletions scripts/cypress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ "$1" = "fast" ]; then
./scripts/cypress-fast-specs.sh && ./node_modules/.bin/cypress run
elif [ "$1" = "open" ]; then
./node_modules/.bin/cypress open --config-file cypress.template.mjs
else
./node_modules/.bin/cypress run --config-file cypress.template.mjs
fi

0 comments on commit 54812b0

Please sign in to comment.