JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 334
  • Score
    100M100P100Q113622F
  • License MIT

A Cypress plugin which restarts tests on webpack-dev-server HMR updates

Package Exports

  • cypress-hmr-restarter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cypress-hmr-restarter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cypress-hmr-restarter

A rudimentary Cypress plugin(?) for automatically restarting tests after Webpack Hot Module Replacement (HMR) updates.

npm version npm downloads

Setup

1. Install

npm install --save-dev cypress-hmr-restarter

2. Import

// E.g. in cypress/support/index.js

// For webpack HMR (used in e.g. create-react-app)
import 'cypress-hmr-restarter';

// For webpack-hot-middleware (used in e.g. gatsby)
import 'cypress-hmr-restarter/gatsby';

3. Make sure baseUrl is defined in your cypress.json

{
  // E.g. when using default config of create-react-app:
  "baseUrl": "http://localhost:3000"
}

What it does

When using the Cypress Test Runner (cypress open), after the window has loaded, it will try to connect and listen for events. When an event signifying a change has happened, after a short delay, it will find the restart button in the sidebar and click it for you.

  • The default import connects to the webpack-dev-server websocket, which is assumed to run at wss://<baseUrl>/sockjs-node, and listens for messages with the type invalid.

  • The gatsby import connects to the webpack-hot-middleware endpoint, assumed to run at <baseUrl>/__webpack_hmr, and listens for messages with the action built.