cypress-delete-downloads-folder
Cypress custom commands and hooks to delete Cypress.config('downloadsFolder')
folder
Installation
npm i -D cypress-delete-downloads-folder
Usage
cypress-delete-downloads-folder extends Cypress' cy command.
So, if you want to use custom cy.deleteDownloadsFolder()
command then you need to add this line to your project's cypress/support/commands.js
:
require('cypress-delete-downloads-folder').addCustomCommand();
And add the following lines to your project's cypress/plugins/index.js
:
const { removeDirectory } = require('cypress-delete-downloads-folder');
module.exports = (on, config) => {
on('task', { removeDirectory })
}
Then, in your test, you can use it like this:
cy.deleteDownloadsFolder();
Also, you can use custom hooks to delete downloads folder before or after tests execution:
const { deleteDownloadsFolderBeforeAll } = require('cypress-delete-downloads-folder');
describe('delete downloads folder before all', () => {
deleteDownloadsFolderBeforeAll()
it('should work', () => {})
})
const { deleteDownloadsFolderBeforeEach } = require('cypress-delete-downloads-folder');
describe('delete downloads folder before each', () => {
deleteDownloadsFolderBeforeEach()
it('should work', () => {})
})
const { deleteDownloadsFolderAfterAll } = require('cypress-delete-downloads-folder');
describe('delete downloads folder after all', () => {
deleteDownloadsFolderAfterAll()
it('should work', () => {})
})
const { deleteDownloadsFolderAfterEach } = require('cypress-delete-downloads-folder');
describe('delete downloads folder after each', () => {
deleteDownloadsFolderAfterEach()
it('should work', () => {})
})
Types
To enable IntelliSense information and autocomplete you have to include types in the tsconfig.json
file:
{
"compilerOptions": {
"types": ["cypress", "cypress-delete-downloads-folder"]
}
}
Author
Yevhen Laichenkov elaichenkov@gmail.com
License
MIT