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 Password Reset Post Challenge action redirects the user to an external identity verification page when their risk score exceeds a threshold, then validates the returned session token and verification result before allowing the password reset to continue.
mock-redirects.js

Unit Test

The unit tests mock the event and api objects, along with the redirect token encoding and validation, to verify the redirect only fires above the risk threshold and that access is denied for invalid tokens, mismatched users, or incomplete verification.
mock-redirects.spec.js
Add the test dependencies to package.json:
package.json
Configure jsconfig.json so the actions: import alias resolves to src/:
jsconfig.json
mock-redirects.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
mock-redirects.spec.js
Add the test dependencies to package.json:
package.json
Configure jsconfig.json so the actions: import alias resolves to src/:
jsconfig.json