0.0.6 • Published 9 months ago

@herdwatch/cy-verify-downloads v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

cy-verify-downloads tests Total npm downloads

This is a Cypress custom command to wait and to verify that a file has been successfully downloaded.

Installation

npm i -D @herdwatch/cy-verify-downloads

Usage

cy-verify-downloads extends Cypress' cy command.

So, you need to add this line to your project's cypress/support/commands.js:

require('@herdwatch/cy-verify-downloads');

OR

cypress/support/commands.ts:

import '@herdwatch/cy-verify-downloads';

And extend module.exports the following lines to your project's cypress/plugins/index.js:

module.exports = (on, config) => {
    require('@herdwatch/cy-verify-downloads/plugin')(on, config);
}

Then, in your test, you can use it like this:

cy.verifyDownload('picture.png');

// or increase timeout
cy.verifyDownload('archive.zip', { timeout: 25000 });

// or increase timeout and interval pooling
cy.verifyDownload('archive.zip', { timeout: 25000, interval: 600 });

// or use with another commands
cy.verifyPdfDownload('test.pdf')

Cypress.Commands.add('verifyPdfDownload',
  (fileName, options) => {
    const exportPdfButton = cy.get('[data-cy="pdf"]');
    exportPdfButton.should('exist');
    exportPdfButton.click();
    cy.verifyDownload(fileName, options);
  }
);

Types

Autocompletion

To enable IntelliSense information and autocomplete you have to include types in the tsconfig.json file:

{
  "compilerOptions": {
    "types": ["cypress", "@herdwatch/cy-verify-downloads"]
  }
}

Author

Yevhen Laichenkov elaichenkov@gmail.com

License

MIT

0.0.6

9 months ago