Svish / Cypress Hmr Restarter
Programming Languages
Projects that are alternatives of or similar to Cypress Hmr Restarter
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';
baseUrl
or hmrUrl
is configured
3. Make sure either // 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
.