Test Mode (Web SDK Only)

Magic client SDKs provide Test Mode as a quick way to test your integration locally by asserting specific error codes or bypassing the magic link flow completely.

Usage

To enable Test Mode, provide testMode: true to the SDK constructor.

import { Magic } from 'magic-sdk';
const magic = new Magic('YOUR_API_KEY', {
testMode: true,
});

With Test Mode enabled, you can assert the desired behavior through the email address you provide to loginWithMagicLink.

To assert a success state, use test+success@magic.link.

magic.auth.loginWithMagicLink({ email: 'test+success@magic.link' });
warning

Users created in test mode are ephemeral. It is advised that you do not associate these users to persistent data in your backend. If you are building an integration with cryptocurrency or Web3 features, never deposit money into a test user's account.

To assert a failed state, use test+fail@magic.link.

magic.auth.loginWithMagicLink({ email: 'test+fail@magic.link' });

To assert a specific failed state, you can also provide an RPC error code with test+fail_with_{RPC_ERROR_CODE}@magic.link.

import { RPCErrorCode } from 'magic-sdk';
magic.auth.loginWithMagicLink({ email: `test+fail_with_{${RPCErrorCode.MagicLinkFailedVerification}}@magic.link` });
magic.auth.loginWithMagicLink({ email: `test+fail_with_{${RPCErrorCode.MagicLinkExpired}}@magic.link` });
magic.auth.loginWithMagicLink({ email: `test+fail_with_{${RPCErrorCode.MagicLinkRateLimited}}@magic.link` });
...

You can find a list of relevant RPC error codes here.