Question

Is it possible to write a unit test for input fields?

  • 5 April 2022
  • 3 replies
  • 141 views

Userlevel 1

*For Zapier CLI

I am currently working on writing unit tests for my zapier App. The documentation doesn’t really give me a good example of this, but is it possible to write unit tests to cover your input fields that contain altersDynamicFields?

The reason why I would like to test this is because the input fields actually makes a call to my API that influences certain fields to appear because the input field has the altersDynamicFields property.

Anybody know a good route for this?


3 replies

Userlevel 1

Did you manage to find an answer to this?

Userlevel 3
Badge +6

Hey @Ryan Learner , 

Excellent question, and apologies this isn’t covered in the docs. I definitely see how helpful that would be. 

Yes, I think this should be doable. 

My main suggestion would be the following:

When invoking appTester in the test, instead of passing the perform, like this (from the example in the docs)...

    const results = await appTester(
App.triggers.recipe.operation.perform,
bundle
);

...pass inputFields, like this:

    const results = await appTester(
App.triggers.recipe.operation.inputFields,
bundle
);

results should then be an array of field definitions. This way, you can run tests with different bundle.inputData mock values and test what fields are/aren’t created.

Does this give you a rough idea of where to start?

Userlevel 1

Thanks @connorz. That works!

 

Just as a side note, the typescript interface for `appTester` doesn’t like passing `App.triggers.recipe.operation.inputFields` as it doesn’t take `bundle` so needs to be cast.

Reply