Testing Your App
The CLI includes automated testing using the Jest testing framework. This is a super useful tool and it's a highly encouraged development practice to have as much test coverage as possible for your app.
To test the GitHub example app we'll need to set up some local environment variables so that the tests can connect to your account and test repo.
Open the .env file. You'll see some variables with some placeholders.
# CLIENT_ID=1234
# CLIENT_SECRET=asdf
Replace those with your GitHub Client ID and Client Secret, removing the # and save the file.
Now, go ahead and run zapier test.
zapier test
If everything worked you'll see a message like:
Validating project locally
No structural errors found during validation routine.
This project is structurally sound!
✔ Running integration checks ... 22 checks passed
Adding /Users/marinahand/.zapierrc to environment as ZAPIER_DEPLOY_KEY...
Running test suite with the following command:
npm run --silent test --
PASS test/authentication.test.js
oauth2 app
✓ generates an authorize URL (30 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.56 s
Ran all test suites.
Note that this tutorial includes limited tests to illustrate the capabilities. You’ll want to write more comprehensive tests for your integration.
If you get errors, try zapier test --debug to get more information. Check your .env file to confirm everything looks right there.