Based off the amazing work of the cypress team at https://github.com/cypress-io/cypress/blob/develop/npm/webpack-dev-server/
Implements the APIs for Cypress Component-testing with Rust-based web bundler Rspack's dev server.
Install the library to your devDependencies
npm install -D cypress-rspack-dev-server
import { devServer } from "cypress-rspack-dev-server";
import { defineConfig } from "cypress";
export default defineConfig({
component: {
devServer(devServerConfig) {
return devServer({
...devServerConfig,
framework: "react",
rspackConfig: require("./rspack.config.js"),
});
},
},
});
Option | NOTES |
---|---|
framework | react , currently only react , will support other frameworks |
cypressConfig | Cypress Plugin Configuration |
specs | Array of Cypress Spec |
devServerEvents | Nodejs EventEmitter |
rspackConfig (Optional) | Rspack Configuration, can be require from rspack config file |
onConfigNotFound (Optional) | The callback function when config not found |
import config from './rsbuild.config.ts';
async devServer(devServerConfig) {
const rsbuild = await createRsbuild({ rsbuildConfig: config });
const rsbuildConfigs = await rsbuild.initConfigs();
const rspackConfig = rsbuildConfigs[0];
rspackConfig?.module?.rules?.push({
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
plugins: ['istanbul'],
},
},
enforce: 'post',
});
return devServer({
...devServerConfig,
framework: 'react',
rspackConfig: rspackConfig,
});
}
In version 1, we supports the Cypress 14 's justInTimeCompile, the specs structure has been updated. If you still use Cypress <= 13, please use the version 0.0.x.
This project is licensed under the terms of the MIT license.