Socket
Book a DemoInstallSign in
Socket

cypress-downloadfile

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-downloadfile

Cypress custom command to download files

1.2.4
latest
Source
npmnpm
Version published
Weekly downloads
78K
-23.44%
Maintainers
1
Weekly downloads
 
Created
Source

cypress-downloadfile

npm version

This is a Cypress custom file download command.

This repository is not maintained by the Cypress developers.

"Buy Me A Coffee"

Installation

Install the module.

npm install cypress-downloadfile

Add the following line to cypress/support/commands.js.

require('cypress-downloadfile/lib/downloadFileCommand')

For Cypress 10 and above

Add the following lines to cypress.config.js.

const { defineConfig } = require('cypress')
const {downloadFile} = require('cypress-downloadfile/lib/addPlugin')

module.exports = defineConfig({
  // setupNodeEvents can be defined in either
  // the e2e or component configuration
  e2e: {
    setupNodeEvents(on, config) {
         on('task', {downloadFile})
      }
    }
})

For all Cypress versions below 10

Add the following lines to cypress/plugins/index.js.

const {downloadFile} = require('cypress-downloadfile/lib/addPlugin')
module.exports = (on, config) => {
  on('task', {downloadFile})
}

If autocompletion does not work out of the box you can add the following line above your testfile

/// <reference types="cypress-downloadfile"/>

Example of basic command

cy.downloadFile('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg','mydownloads','example.jpg')

In Version 1.1.5 you can now also pass in the User-Agent. If no User-Agent is passed it will give a default User-Agent called request.

cy.downloadFile('https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg','mydownloads','example.jpg','MyCustomAgentName')

Version 1.2.0

Because request is deprecated we changed to cross-fetch. This works on Cypress 3.8.0 and upwards. If you notice problems please let me know

Keywords

Cypress

FAQs

Package last updated on 17 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.