Zuplo CLI
Test Command
Use the test command to help you test your zup by running integration tests against it.
Writing Tests#
Tip
Your test files need to be under the tests
folder and end with .test.ts
to
be picked up by the Zuplo CLI.
Using Node.js 18 and the Zuplo CLI, it is very easy to write tests that make
requests to your API using fetch
and then validate expectations with expect
from chai.
Checkout our other sample tests to find one that matches your use-case.
Running your tests#
Once you have written your tests, you can run them using the test
command.
Environment Variables#
Environment variables can be used in tests and referenced using the TestHelper
object.
Environment variables can be loaded from the shell or set in a .env
file at
the root of your project.
For example, to set a value inline run the test command as shown.
Alternatively, create an .env
file and set a value as shown.
Any global environment variables on the system will also be available inside your tests.
Using environment variables in the test is done via the TestHelper
as
demonstrated below.
Tip
When running tests in a CI environment, secrets such as API Keys or tokens can be stored in the secret variable store of your test system and injected at the time you run the tests.
Tips for writing tests#
Take a look at our other testing tips.