I’m wanting to create some cucumber BDD tests which can be run either locally or in CI to test my API end-to-end. BTW there is no frontend for this, just APIs. As an example I’m wanting to publish an event on Event Bridge and then validate that the handler has processed that correctly by checking the database and output events being raised.
How should I setup my SST to be able to run these? Do I need to have them running in a stack? Can I start my sst stacks up, execute my feature file tests and then stop the sst? Without doing that, how can I get the endpoints and the credentials I need to be available to the tests?
f
Frank
05/24/2022, 11:40 PM
Hey @jamlen, testing against a deployed stack makes sense.
Frank
05/24/2022, 11:40 PM
You can either deploy the stack (ie.
sst deploy --outputs-file outputs
), read the outputs, run tests against it, and then clean up the stack (ie.
sst remove
).
Frank
05/24/2022, 11:40 PM
Or, you can have a long-lived testing stack, and test against it.
Frank
05/24/2022, 11:41 PM
In your test, you’d probably want to do something like expect the DB to be written in X seconds.
p
Paul Swail
05/25/2022, 1:23 PM
also, to make sure your test won’t be flaky, you can use the async-retry module inside your test cases. I wrote about this here