We are very excited about the release of Actions, which provide an export that can be used for testing purposes, unlike Rules.
Since the Actions typically do not return something like a callback, what are the recommended strategies for unit testing these functions? I have not found any documentation around testing Auth0 code. This also applies to database connection scripts, although without any exports, I am unsure of how to go about testing those at all. Any ideas are appreciated!
Hey there! Unfortunately as of now we still don’t have any content around it but I was asked by the team to ask you to file a feature request for that using our Feedback category here:
It’s unfortunate to hear this is treated as a feature request, when it’s really just basic documentation for using the product. I should not need to request a feature to know how to use something. Surely the development team is creating features with testing capabilities in mind, it would be great to even share the recommended strategies.
The team indeed made some design decisions around the architecture used in Actions so that they could eventually offer a nice DX for customers to unit test Actions in isolation but the guide is not live yet.
Further to this it would be extremely useful if auth0 released a package to help with testing actions. As it is we have to create quite extensive mocks for the event & api arguments, it’s quite feasible that our tests may pass but because we have mocked out the api interface wrongly it will not work in auth0.
Hi @ben_wozniak! Giving my two cents, I think you can unit test your Action mocking all the contracts. However, I understand this one is not suitable for some critical scenarios. So, I recently did a small project showing how to test your Action when the scenario is ready on Auth0 platform. As it is right now, the only drawback is that you must create your scenario by hand before the test execution. This can automatically be done through the Management API, though.
I don’t know if we’re going to use Auth0 in a project I’m responsible for. Still, if that is the case, we intend to create a fully automated test for Actions using the following:
Management API: We can make the test case and evaluate the result after a flow is completed using it.
Functional Testing: Responsible for executing the flow as the user would do.
Just wanted to let everyone know that we just published a more complete guide on testing Actions. Please take a look and let us know in this thread if there is anything missing that you’d like to be able to do.