The Canva Apps SDK, Connect APIs, and MCP are now unified in the Canva Developers SDK. Learn more(opens in a new tab or window).
Canva Developers SDK
The Canva Apps SDK, Connect APIs, and MCP are now unified in the Canva Developers SDK. Learn more(opens in a new tab or window).

initTestEnvironment

API reference for the initTestEnvironment method.

Initializes a test environment for the @canva/error 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 error from "@canva/error/test";
// Initialize the test environment
error.initTestEnvironment();
// The `@canva/error` package does not need to be mocked.
TYPESCRIPT

Returns

void