Testing
Rstack uses Rstest to run tests.
For command-line options and subcommands, see rs test.
Configure tests
Register an Rstest configuration with define.test(). It accepts the same configuration as Rstest's defineConfig():
Test APIs
Import test APIs and configuration helpers from rstack/test:
Single project
For a single test project, pass the Rstest options directly to define.test():
When extends is omitted, Rstack uses the Rsbuild adapter to extend the test configuration from define.app(). If no application configuration is defined, it uses the Rslib adapter with define.lib() instead. define.app() takes precedence when both are defined.
Multiple projects
Set Rstest's projects option to run multiple test configurations together. Entries can be inline projects or strings that Rstest resolves as external projects.
Inline projects
Use inline projects when different test environments should share the current application or library configuration:
Rstack applies the corresponding adapter to each inline project that omits extends. A function-based define.app() or define.lib() configuration is resolved once, then shared by those inline projects.
Run one project by name:
See examples/rstest-inline-projects for a complete React SSR example using Node.js and happy-dom.
External projects
Use a string entry for an externally configured project:
Rstack passes string entries to Rstest unchanged. External projects load their own configuration and do not inherit the current define.app() or define.lib() configuration. Use external projects when each project manages its configuration independently.
Customize inheritance
Set Rstest's extends option explicitly when a project should not inherit the current application or library configuration:
Setting extends on an inline project disables automatic inheritance only for that project. Setting it on the root define.test() configuration disables automatic inheritance for the entire test configuration.