I am developing a new zap integration.
During the tests executed via “zapier test” is it possible to manipulate a MongoDB database to create new entities (user, oAuthClient, items, ...) allowing me to test authentication, triggers and actions on real datas.
Thanks in advance
Best answer by Zane
If I understand the question right, short answer is yes.. you can configure the code that your CLI test suite runs to do pretty much anything you can do from your local environment.
I’m assuming you want to build in a setup script that seeds your API/back end with test data, that your subsequent tests of your triggers and actions have guaranteed results you can build assertions around.
If you use the scaffolding took in the CLI, we currently configure your project to use Jest. And you’ll find lots of good examples on the web of configuring test suites with setup and teardown configurations. You can also swap out to another node testing library if you prefer.
A different way to go, is to use a mock library, so that you’re not dependent on the configuration of the back end and can focus on fast testing of just your Zapier integration logic. Something like nock, one that some folks here like to use.
Both approaches have their strengths. And both should be augmented by testing by making real Zaps in the the Zapier product, and running each trigger and action before putting any integration version into production.