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-slow-down

v1.3.1

Published

Slow down your Cypress tests

Downloads

147,621

Readme

cypress-slow-down cypress version ci cypress-slow-down

Slow down your Cypress tests

Watch the introduction to this plugin in the video Slow Down Cypress Tests. For advanced usage, see the lessons in my Cypress Plugins course.

One command per second

Install

Add this NPM package to your project

# install using NPM
$ npm i -D cypress-slow-down
# or install using Yarn
$ yarn add -D cypress-slow-down

Include the plugin and call its function from your spec or support file

// cypress/e2e/spec.cy.js
// https://github.com/bahmutov/cypress-slow-down
import { slowCypressDown } from 'cypress-slow-down'
// slow down each command by the default amount
// which is 1 second
slowCypressDown()

Options

You can control the delay before each command (in milliseconds)

// when calling the slowCypressDown function
slowCypressDown(1000)

You can also control the delay using the Cypress environment variable commandDelay.

// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    env: {
      // https://github.com/bahmutov/cypress-slow-down
      commandDelay: 500,
    },
  },
})
// cypress/e2e/spec.cy.js
import { slowCypressDown } from 'cypress-slow-down'
slowCypressDown() // slows down each command by 500ms

You can set the optional logToConsole parameter to false to prevent the plugin from logging each delay to the console.

slowCypressDown(1000, false)

Disable the slow down

You can disable the default slowdown by using false. For example, from the command line you can pass the boolean value:

$ npx cypress run --env commandDelay=false

Or you can use the process (OS) environment variable

$ CYPRESS_commandDelay=false npx cypress run

Or you can use the cypress.config.js to disable the slowdown

// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    env: {
      // https://github.com/bahmutov/cypress-slow-down
      commandDelay: false,
    },
  },
})

Change the command delay from DevTools

Because this plugin uses cypress-plugin-config to read the command delay option, you can change its value or disable the plugin completely from the DevTools console using the command Cypress.setPluginConfigValue('commandDelay', <value>)

Change the command delay from the DevTools

The re-run the tests by pressing the key "R" or clicking "Run All Tests" button.

Child commands

You can slow down a part of your test by using the custom dual commands cy.slowDown(ms) and cy.slowDownEnd().

// your spec file
// cypress/e2e/spec.cy.js
// https://github.com/bahmutov/cypress-slow-down
import { slowCypressDown } from 'cypress-slow-down'
// registers the cy.slowDown and cy.slowDownEnd commands
import 'cypress-slow-down/commands'
// must enable the plugin using slowCypressDown
// can disable the slow down by default or use some default delay
slowCypressDown(false)

it('runs the middle part slowly', () => {
  cy.visit('/')
  cy.get('...').should('...').slowDown(1000)
  // these commands have 1 second delay
  ...
  cy.slowDownEnd()
  // back to the normal speed
})

Tip: to see how the commands are slowed down you can use the cypress-timestamps plugin.

Small print

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

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