Skip to main content

Project

Each example separates the action’s source code under src/ from its unit tests under test/, following the same structure across JavaScript and TypeScript projects.
/
src
test

Action

The following Post Login action checks the user’s roles from event.authorization and sets them as a custom claim on the ID token, denying access when no roles are present.
test-an-action.js

Unit Test

The unit tests mock the event and api objects to verify that admin users get the custom claim set, while users with no roles or a missing authorization object are denied access.
test-an-action.spec.js
Add the test dependencies to package.json:
package.json
Configure jsconfig.json so the actions: import alias resolves to src/:
jsconfig.json
test-an-action.spec.js
Add the test dependencies to package.json:
package.json
Configure Mocha with .mocharc.json:
.mocharc.json
Configure jsconfig.json so the actions: import alias resolves to src/:
jsconfig.json
test-an-action.spec.js
Add the test dependencies to package.json:
package.json
Configure jsconfig.json so the actions: import alias resolves to src/:
jsconfig.json