Best answer

Is it possible to load data from database during test a new zap integration

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 11 May 2021, 16:19

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +11

Hi @akta3d!

I don’t think that’s possible but let me see if we can get a more definitive answer for you :) @Zane are you able to confirm whether what @akta3d is asking is possible?

Userlevel 7
Badge +9

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. 

Thanks @Zane 

You understand my question. Sorry for my poor english?

Yes the goal is to avoid mockking request, I prefer use a testing database, add seeds before running tests and run test on a real environment.