npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-watch-and-reload

v1.10.14

Published

Reloads Cypress when one of the watched files changes

Downloads

38,707

Readme

cypress-watch-and-reload CircleCI renovate-app badge

Reloads Cypress when one of the watched files changes

🎓 Covered by my courses Cypress Plugins and Testing The Swag Store.

Video

Watch this plugin in action in the short video Re-run Cypress Tests When Application Files Change and Nodemon And cypress-watch-and-reload Utilities

Install

npm install -D cypress-watch-and-reload
# or using Yarn
yarn add -D cypress-watch-and-reload

Cypress v10+

Load this plugin from your cypress.config.js file

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    env: {
      // list the files and file patterns to watch
      'cypress-watch-and-reload': {
        watch: ['page/*', 'circle.yml'],
      },
    },
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on, config) {
      // https://github.com/bahmutov/cypress-watch-and-reload
      return require('cypress-watch-and-reload/plugins')(on, config)
    },
  },
})

Add to your cypress/support/e2e.js file

require('cypress-watch-and-reload/support')

Note: this plugin will work if you pass both on and config arguments, or just the config argument.

// pass both arguments
require('cypress-watch-and-reload/plugins')(on, config)
// or pass just the config object
require('cypress-watch-and-reload/plugins')(config)

Important: make sure to return the plugin registration or the config object

// return the registration
setupNodeEvents(on, config) {
  return require('cypress-watch-and-reload/plugins')(on, config)
}
// or return the config object
setupNodeEvents(on, config) {
  require('cypress-watch-and-reload/plugins')(on, config)
  return config
}

Cypress v9

Add to your cypress/plugins/index.js file

module.exports = (on, config) => {
  // https://github.com/bahmutov/cypress-watch-and-reload
  require('cypress-watch-and-reload/plugins')(config)
  // IMPORTANT: return the config object
  // because the plugin might have changed it
  return config
}

Add to your cypress/support/index.js file

require('cypress-watch-and-reload/support')

In your cypress.json set wildcard with files to watch. For example

{
  "cypress-watch-and-reload": {
    "watch": "page/*"
  }
}

Every time you change one of the files matching the wildcard, Cypress will reload itself, rerunning the tests.

You can use a list of files / wildcard patterns to watch:

{
  "cypress-watch-and-reload": {
    "watch": ["page/*", "src/*.js"]
  }
}

This package uses chokidar under the hood, see plugins.js. The client-side setup is disabled if you are running Cypress in non-interactive mode using cypress run command.

UI

There is a button to disable watching the files, which is useful sometimes to modify lots of files before running the tests.

Toggle button

Example

See the projects cypress-watch-and-reload-example and chat.io

Details

This plugin opens a WebSocket connection from Cypress to its Node backend. The backend is watching the specified files. Whenever you change a file, Cypress will notice and will reload itself, rerunning tests.

Development

To see the plugin in action, open Cypress in this repository

npm run cy:open

Then edit and save any file in the "page" folder and see the tests re-run automatically.

Small print

Author: Gleb Bahmutov <[email protected]> © 2020

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2020 Gleb Bahmutov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.