-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve atomicity of E2E tests (#650)
### Issue The e2e test runner was setting ENV from multiple sources leading cognitive complexity when reading, writing, and running tests. In particular, Github vars were passed as part of `deno task test` while STRIPE entities were not. ### Observations 1. Tests had different outcomes if run outside of the deno.json `test` task. 2. Tests were not atomically runnable as they were unaware of their required ENV vars. 3. A users ENV could alter the outcome of tests ### Improvement I created a `setupEnv` function which defines the base ENV state our application expects and provides a mechanism for mutating it into what a given test requires. 1. All tests start with the same base 2. Tests are atomic 3. Deno task args minimally impact test outcomes (👀 `DENO_KV_PATH`) 6. User ENV minimally impacts test outcomes ### Example Behaviours #### Pass a computed value as the input for an Environment Variable ```javascript const priceId = crypto.randomUUID(); setupEnv( { "STRIPE_PREMIUM_PLAN_PRICE_ID": priceId }, ); ``` #### Ensure an Environment Variable is unset ```javascript setupEnv( { "STRIPE_SECRET_KEY": null }, ); ```
- Loading branch information
Showing
2 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters