Cypress Rspack Dev Server

1.1.2 · active · verified Wed Apr 22

cypress-rspack-dev-server is a Cypress component testing dev server that integrates with Rspack, providing a fast and efficient build toolchain for testing front-end components. It allows developers to leverage Rspack's performance benefits within their Cypress test environment, handling asset compilation and serving for component tests. The current stable version is 1.1.2, though release candidates for 2.0.0 supporting Rspack 2 are actively being developed. The package's release cadence appears to align with major updates to Rspack and Cypress itself, indicating a responsive maintenance schedule rather than fixed intervals. Its primary differentiator is the direct integration with Rspack, offering an alternative to webpack-based dev servers for users already committed to the Rspack ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure Cypress to use `cypress-rspack-dev-server` for component testing with a basic Rspack configuration. It sets up the `devServer` in `cypress.config.ts` to use `createRspackDevServer` and provides a minimal `rspackConfig` object, including SWC loader for TypeScript/JSX.

import { defineConfig } from 'cypress';
import { createRspackDevServer } from '@cypress/rspack-dev-server';
import { Configuration as RspackConfiguration } from '@rspack/core';

const rspackConfig: RspackConfiguration = {
  // Your Rspack configuration for component testing
  mode: 'development',
  resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx'],
  },
  module: {
    rules: [
      {
        test: /\.(js|ts|jsx|tsx)$/,
        exclude: /node_modules/,
        loader: 'builtin:swc-loader',
        options: {
          jsc: {
            parser: {
              syntax: 'typescript',
              jsx: true,
            },
            transform: {
              react: {
                runtime: 'automatic',
              },
            },
          },
        },
      },
    ],
  },
  // Add any other Rspack specific configurations here
};

export default defineConfig({
  component: {
    devServer: {
      framework: 'react',
      bundler: 'rspack',
      rspackConfig,
    },
    devServer: createRspackDevServer,
    specPattern: '**/*.cy.{js,jsx,ts,tsx}',
  },
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

view raw JSON →