Document, test, and refactor our modules #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As part of testing the ops module's functionality, the following changes are proposed:
src
as therootDir
property. Alongside the introduction of the usualjest.config.mjs
file, I've added ajest.env.js
file and set it as thesetupFiles
property of thejest.config.mjs
. The setup file is needed to configure theprocess.env.NODE_ENV
env var for tests that reference or update its value. Similarly, I've added thejest.utils.js
file to hold our various setup and teardown functions in one place.test
command to the package.json scripts. The command runs Jest with the--experimental-vm-modules
flag they currently recommend using to support ES modules.OPS_EMAIL
environment variable and update.env.example
accordingly. The env var allows a dev user to set the email address the script should use when logging in to Firebase and other services.env
,exec
,firebase
, andvalidate
.Test Results
Below are the tests results these changes produce.
PASS src/ops.test.js
PASS src/firebase.test.js
PASS src/logger.test.js
PASS src/validate.test.js
PASS src/gcloud.test.js
PASS src/exec.test.js
-------------|---------|----------|---------|---------|------------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------|---------|----------|---------|---------|------------------------------------
All files | 95.68 | 96.47 | 86.56 | 95.68 |
env.js | 100 | 50 | 100 | 100 | 11
exec.js | 98.01 | 91.66 | 66.66 | 98.01 | 59-60
firebase.js | 96.43 | 100 | 80.95 | 96.43 | 453-470
gcloud.js | 100 | 100 | 100 | 100 |
logger.js | 100 | 100 | 100 | 100 |
ops.js | 90.64 | 90.9 | 77.77 | 90.64 | ...331-338,343-352,365,378,389,396
validate.js | 100 | 100 | 100 | 100 |
-------------|---------|----------|---------|---------|------------------------------------
Test Suites: 6 passed, 6 total
Tests: 113 passed, 113 total
Snapshots: 0 total
Time: 7.761 s, estimated 10 s
Ran all test suites.