Cypress custom command to wait and verify that file has been downloaded
71
stars
431
commits
JavaScript
primary language
Jan 26, 2026
updated
Custom Cypress command to wait and verify that file is downloaded.
npm i -D cy-verify-downloads
This package extends Cypress' cy command.
For Cypress v10+:
Add this line to your project's cypress/support/e2e.js:
require('cy-verify-downloads').addCustomCommand();
Then you need to add the following lines of code to your project's cypress.config.js:
const { verifyDownloadTasks } = require('cy-verify-downloads');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', verifyDownloadTasks);
},
},
});
For Cucumber:
Additionally, you may need to install and add node polyfill in your support/e2e.js file:
npm i -D esbuild-plugin-polyfill-node
support/e2e.js file:const { polyfillNode } = require('esbuild-plugin-polyfill-node');
plugins property:module.exports = defineConfig({
e2e: {
async setupNodeEvents(on, config) {
const bundler = createBundler({
plugins: [polyfillNode({ polyfills: { crypto: true } }), createEsbuildPlugin(config)],
});
}
}
});
For Cypress v9:
So, you need to add this line to your project's cypress/support/commands.js:
require('cy-verify-downloads').addCustomCommand();
And add the following lines to your project's cypress/plugins/index.js:
const { verifyDownloadTasks } = require('cy-verify-downloads');
module.exports = (on, config) => {
on('task', verifyDownloadTasks)
}
Then, in your test, you can use it like this:
cy.verifyDownload('picture.png');
// verify download by file extension or partial filename
cy.verifyDownload('.png', { contains: true });
cy.verifyDownload('pic', { contains: true });
// or increase timeout
cy.verifyDownload('archive.zip', { timeout: 25000 });
// or increase timeout and interval pooling
cy.verifyDownload('archive.zip', { timeout: 25000, interval: 600 });

To enable IntelliSense information and autocomplete you have to include types in the tsconfig.json file:
{
"compilerOptions": {
"types": ["cypress", "cy-verify-downloads"]
}
}
Yevhen Laichenkov elaichenkov@gmail.com
261 commits
170 commits
JavaScript
92.2%
HTML
7.8%
Cypress custom command to wait and verify that file has been downloaded
71
stars
431
commits
JavaScript
primary language
Jan 26, 2026
updated
Custom Cypress command to wait and verify that file is downloaded.
npm i -D cy-verify-downloads
This package extends Cypress' cy command.
For Cypress v10+:
Add this line to your project's cypress/support/e2e.js:
require('cy-verify-downloads').addCustomCommand();
Then you need to add the following lines of code to your project's cypress.config.js:
const { verifyDownloadTasks } = require('cy-verify-downloads');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', verifyDownloadTasks);
},
},
});
For Cucumber:
Additionally, you may need to install and add node polyfill in your support/e2e.js file:
npm i -D esbuild-plugin-polyfill-node
support/e2e.js file:const { polyfillNode } = require('esbuild-plugin-polyfill-node');
plugins property:module.exports = defineConfig({
e2e: {
async setupNodeEvents(on, config) {
const bundler = createBundler({
plugins: [polyfillNode({ polyfills: { crypto: true } }), createEsbuildPlugin(config)],
});
}
}
});
For Cypress v9:
So, you need to add this line to your project's cypress/support/commands.js:
require('cy-verify-downloads').addCustomCommand();
And add the following lines to your project's cypress/plugins/index.js:
const { verifyDownloadTasks } = require('cy-verify-downloads');
module.exports = (on, config) => {
on('task', verifyDownloadTasks)
}
Then, in your test, you can use it like this:
cy.verifyDownload('picture.png');
// verify download by file extension or partial filename
cy.verifyDownload('.png', { contains: true });
cy.verifyDownload('pic', { contains: true });
// or increase timeout
cy.verifyDownload('archive.zip', { timeout: 25000 });
// or increase timeout and interval pooling
cy.verifyDownload('archive.zip', { timeout: 25000, interval: 600 });

To enable IntelliSense information and autocomplete you have to include types in the tsconfig.json file:
{
"compilerOptions": {
"types": ["cypress", "cy-verify-downloads"]
}
}
Yevhen Laichenkov elaichenkov@gmail.com
261 commits
170 commits
JavaScript
92.2%
HTML
7.8%