initTestEnvironment

API reference for the initTestEnvironment method.

This API is only for use in unit testing and shouldn't be part of your main app code.

Initializes a test environment for the @canva/user package, enabling unit tests to mock Canva's APIs.

This method should only be called once in a test environment, such as in a Jest setup file.

Usage: Setting up a test environment

// Import testing sub-package
import * as user from "@canva/user/test";
// Initialize the test environment
user.initTestEnvironment();
// Mock the SDK
jest.mock("@canva/user");
TYPESCRIPT

Returns

void