globals
- Type:
boolean - Default:
false - CLI:
--globals
Inject Rstest APIs (such as expect, test, and describe) into the global scope of test files instead of requiring imports from @rstest/core.
By default, Rstest does not register global APIs. Set globals: true in config or pass --globals on the CLI to enable them (similar to Jest).
Usage
When you enable globals, you can use the global APIs directly without import { ... } from '@rstest/core'.
Available global APIs
When globals is enabled, Rstest injects the following globals:
testdescribeitexpectassertbeforeAllafterAllbeforeEachafterEachonTestFinishedonTestFailedrsrstest
rs and rstest are aliases with the same runtime utilities.
TypeScript support
To enable TypeScript to properly recognize the global APIs, we recommend adding @rstest/core/globals to compilerOptions.types in the tsconfig.json for your test files:
If your
tsconfig.jsonalready configurescompilerOptions.types, append this type to the existing list.
Alternatively, create a src/rstestEnv.d.ts file to reference the type definitions: