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.
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 either baseUrl
or hmrUrl
is configured
// E.g. in cypress.json
{
// Works with e.g. default create-react-app configuration
"baseUrl": "http://localhost:3000"
}
Options
{
// Overrides assuming URL via baseUrl
"hmrUrl": "ws://localhost:3000/socks-node", // default import
"hmrUrl": "http://localhost:3000/__webpack_hmr", // gatsby import
// Overrides delay between event and restart (ms)
"hmrRestartDelay": 1500
}
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, it will first try clicking the stop button, and then, after a short delay, it will click the restart button.
The default import connects to the
webpack-dev-server
websocket at either<hmrUrl>
orws://<baseUrl>/sockjs-node
(wss:
ifhttps:
), and listens for messages with the typeinvalid
.The gatsby import connects to the
webpack-hot-middleware
event source at either<hmrUrl>
or<baseUrl>/__webpack_hmr
, and listens for messages with the actionbuilt
.