0.2.4 • Published 18 days ago

cy-verify-downloads v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
18 days ago

Stand With Ukraine

cy-verify-downloads tests Total npm downloads

Installation

npm i -D cy-verify-downloads

Extend Cypress command

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:

  1. Install the polyfill module:
npm i -D esbuild-plugin-polyfill-node
  1. Import the following code in your support/e2e.js file:
const { polyfillNode } = require('esbuild-plugin-polyfill-node');
  1. Add the following code in your 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)
}

Usage

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 });

Types

Autocompletion

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

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

Author

Yevhen Laichenkov elaichenkov@gmail.com

License

MIT

0.2.4

18 days ago

0.2.3

5 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.1.16

9 months ago

0.1.17

8 months ago

0.2.2

7 months ago

0.1.15

11 months ago

0.1.14

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago