consumerfinance.gov
consumerfinance.gov copied to clipboard
Fast cypress
This PR changes how our cypress functional tests run against changes to code in this repo. It does this by defining a mapping between files & directories of application code and corresponding directories of cypress tests that need to be run. This mapping is defined in the spec-map.js
file and the changed files that are tested against this map are discovered via diffing against main (locally) / using a changed-files action that wraps the diff (in GHA). How this actually affects Cypress is by using the mapping to rewrite a cypress config file with constrained spec paths.
Cypress can be run locally using this mapping with yarn run fast-cypress
. The entire suite can be run locally using yarn run cypress
(as normal).
Broadly speaking, the answer to "what Cypress tests should run against this PR" is usually decently easy to answer and so I expect this naive mapping to mostly function without many false negatives. Indeed, any detected false negatives can just simply be added to the map.
Some choices I made:
- If NO changed files match relevant tests, cypress runs a dummy test that always passes.
- If the spec map, any
requirements
, orpackage.json
(sorry ans_update_deps) are changed, ALL the specs run, as there can be no guarantee that random tests won't fail
Let me know what y'all think!