I am trying to write unit tests for my auth0 postlogin action.
I want to test the other functions in that action but it seems that I can only export the executeOnPostLogin function to testing. If I try to add logic to the action to export other functions then the action will break in Auth0.
In terms of unit testing the tenant, our recommended way of doing so is by cloning the action code to your environment for mocking and testing purposes. Here you can read more about that → Test Actions
I have a quick workaround for it. I made a CI pipeline.
In code, the action has an export statement for the other functions. I then just run jest tests against the file. When i am about to deploy the action to the auth0 tenant I just remove the export statement from the payload.
I just script our the action above.
There should definitely be a better way of unit testing provided by auth0 though
@caward24 That’s essentially what we’ve released in our open source Actions Testing Library mentioned above (NPM, GitHub), but we’ve also done all the work of letting you mock realistic events and easily testing assertions. Check it out, and let us know via GitHub issues if you have any questions. We use this in production for multiple Auth0 customers.