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 Pre User Registration action denies signups from a forbidden email domain, requires a full name to be submitted, and otherwise stores that name in user_metadata along with a randomly generated identifier in app_metadata.
mock-dependencies.js

Unit Test

The unit tests mock the event and api objects to verify that the forbidden domain is denied, that a missing full name triggers a validation error, and that a valid submission stores the full name and a correctly formatted UUID.
mock-dependencies.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-dependencies.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-dependencies.spec.js
Add the test dependencies to package.json:
package.json
Configure jsconfig.json so the actions: import alias resolves to src/:
jsconfig.json