Test harness for Code steps (Unit and Integration Testing) - prevent repeated errors turning off Zap

  • 4 September 2021
  • 3 replies

Userlevel 2

If a code block fails repeatedly, Zap Manager will disable the Zap.

Good programming practices would exercise a code block in a unit test, essentially putting the code through scenarios known to have caused problems before (regression testing) and boundary conditions that can have dubious scenarios.

These can avoid failures, exceptions and unwanted results.

Question - what do you recommend for unit testing?


P.S. yes, I understand I can upload code blocks as AWS Lambdas and test them there. I’m looking for something simpler.


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

Hey @mrjcleaver!

It looks like a similar question was asked on how to catch errors in a Code step to prevent it from erroring over here:

Hopefully the suggestion in that related thread will be helpful to you in preventing your Zap from being switched off automatically. :)​​​

Userlevel 2

Hi @SamB - it's marginally related. Thanks for looking.

It's one thing is how to address a particular code block (check for each key, and value, and wrap the whole thing in a try/catch).


What I'm asking about is how to make sure the team has done that for every code block. i.e. there is professionalism throughout in every zap.


Whereas no-code environments like Zapier is targeted as being easy for non-coders, Zapier should still provide dependable results.


Test harnesses exercise pieces of functionality to achieve this.

Userlevel 7
Badge +11

Ah, I see! Sorry for my misunderstanding here previously, @mrjcleaver

I don’t believe we have a recommended unit testing process documented for Code by Zapier steps, but with our developer platform we do recommend using the Jest framework for unit testing. You can find out more about that here: Writing Unit Tests  

Hope that helps!