Log in with email OTP codes
Your app emails a one-time passcode to the provisioned inbox, and a JavaScript step in the test fetches the latest message and pulls the code out. Use this recipe when login arrives as a code instead of a link.Prerequisite: A Momentic-provisioned inbox (
@usemomentic.com or
@gomomentic.com). Request one.Fetch the code
Add a JavaScript step that reads the latest email, parses the code, and saves it to the environment. Setinbox to your provisioned inbox.
{{ env.OTP_CODE }} targeting the OTP
input.
Related
Log in with SMS OTP codes
Your app texts a one-time passcode to the provisioned number, and a JavaScript step in the test fetches the latest message and pulls the code out. Use a single number for serial runs; lease numbers from a pool when tests run in parallel through the CLI.Prerequisite: A Momentic-provisioned phone number. Request
one.
Single-number setup
If you only need OTP login from one fixed number (or your tests don’t run in parallel), fetch the latest message and pull the code out:{{ env.OTP_CODE }}.
Parallel CLI runs against the same OTP flow
If you run the same OTP login test in parallel (e.g. multiple shards in CI), two tests can race on the same inbound code. Lease a number from your pool so each shard gets its own. Momentic releases it back to the pool when the test finishes. Lease the number, have your app send the code to it, then fetch the code:sms.lease() for full options (TTL,
fail-fast, optional manual release).
Related
Log in with email verification links
Your app emails a magic login link to the provisioned inbox, and a JavaScript step in the test fetches the latest message and pulls the link out. Use this recipe when login arrives as a URL instead of a code.Prerequisite: A Momentic-provisioned inbox. Request
one.
Fetch and navigate
Add a JavaScript step that fetches the latest email, extracts the verification link, and saves it to the environment. Setinbox to your
provisioned inbox.
{{ env.VERIFICATION_LINK }}.
Related
Log in with OTPAuth (TOTP)
Prerequisite: A Base32 TOTP secret (shown during 2FA enrollment) or an
otpauth:// URI (often embedded in a QR code).otpauth library, which Momentic
preloads in the step sandbox. Reach for this when a login flow asks for an
authenticator-app code.
From a Base32 secret
From an otpauth:// URI
{{ env.TOTP_CODE }}.
Related
Cache authenticated sessions
In web tests, cache the login module to reuse saved browser state across runs. This reduces repeated sign-ins and requests to your auth provider.Setup
- Extract your login steps into a Module. The last step should verify the authenticated state (e.g. an Element check for the dashboard heading).
- In the module config, turn on Enable caching globally
(
defaultCacheAllInvocations) and Treat as auth module (autoAuth). - Set a Default cache key (
defaultCacheKey, e.g.admin-user). Parallel tests sharing the key reuse the same cached session. - Set Default expiry seconds (stored as
defaultCacheTtlin milliseconds) shorter than your session lifetime. - Remove any Save auth state / Load auth state (
authSave/authLoad) steps. A cached auth module saves and restores the state automatically; see Save and restore a state file.
log-in.module.yaml
before section:
checkout.test.yaml
What gets cached
Momentic captures cookies,localStorage, and IndexedDB when the module
finishes. On subsequent runs within the expiry window, it restores that state
and skips the module’s steps.
Related
Test Vercel protected preview environments
Prerequisite: A Vercel protection bypass
secret.