For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /integration/rslib/index.md.
close
  • English
  • Rslib

    Rslib is a library development tool built on Rsbuild for creating JavaScript libraries and UI component libraries.

    If your library uses Rslib, you can use Rstest to test it and reuse the test-relevant parts of your Rslib configuration through an adapter. This reduces duplicate configuration and helps keep test compilation consistent with your library build.

    Quick start

    New project

    Create a new Rslib + Rstest project with the --tools rstest flag:

    npx create-rslib --template react-ts --tools rstest --dir my-project

    The scaffold includes Rstest and demo tests. Run them with npm run test.

    Existing project

    To add Rstest to an existing project, follow the Quick Start to install and set up test scripts.

    Reuse Rslib config

    @rstest/adapter-rslib loads your Rslib config and converts the test-relevant parts into Rstest configuration.

    Install adapter

    npm
    yarn
    pnpm
    bun
    deno
    npm add @rstest/adapter-rslib -D

    Extend your config

    rstest.config.ts
    import { defineConfig } from '@rstest/core';
    import { withRslibConfig } from '@rstest/adapter-rslib';
    
    export default defineConfig({
      extends: withRslibConfig(),
    });

    The adapter loads rslib.config.ts, maps options used by test compilation, merges them with your Rstest config, and adds the loaded config file to forceRerunTriggers, so --changed runs the full test suite when that config changes.

    It does not copy build-only settings such as dev, server, or html. Use cwd, config, or libId when the default config location or library selection does not match your project.

    For all options, configuration mapping, cache behavior, and debug instructions, see the configuration reference.