https://github.com/elaichenkov/cypress-delete-downloads-folder
Custom cypress commands and hooks to delete downloads folder before or after tests execution
https://github.com/elaichenkov/cypress-delete-downloads-folder
cypress cypress-custom-command cypress-io cypress-plugin cypress-tests e2e e2e-testing e2e-tests javascript library
Last synced: about 1 month ago
JSON representation
Custom cypress commands and hooks to delete downloads folder before or after tests execution
- Host: GitHub
- URL: https://github.com/elaichenkov/cypress-delete-downloads-folder
- Owner: elaichenkov
- License: mit
- Created: 2022-02-18T16:12:06.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T00:38:43.000Z (about 2 months ago)
- Last Synced: 2025-03-11T01:27:52.491Z (about 2 months ago)
- Topics: cypress, cypress-custom-command, cypress-io, cypress-plugin, cypress-tests, e2e, e2e-testing, e2e-tests, javascript, library
- Language: JavaScript
- Homepage:
- Size: 1.51 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cypress-delete-downloads-folder  [](https://www.npmjs.com/package/cypress-delete-downloads-folder)
Cypress custom commands and hooks to delete `Cypress.config('downloadsFolder')` folder
## Installation
```shell
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`:
```javascript
require('cypress-delete-downloads-folder').addCustomCommand();
```And add the following lines to your project's `cypress/plugins/index.js`:
```javascript
const { removeDirectory } = require('cypress-delete-downloads-folder');module.exports = (on, config) => {
on('task', { removeDirectory })
}
```Then, in your test, you can use it like this:
```javascript
cy.deleteDownloadsFolder();
```Also, you can use custom hooks to delete downloads folder before or after tests execution:
```javascript
const { deleteDownloadsFolderBeforeAll } = require('cypress-delete-downloads-folder');describe('delete downloads folder before all', () => {
deleteDownloadsFolderBeforeAll()it('should work', () => {})
})
``````javascript
const { deleteDownloadsFolderBeforeEach } = require('cypress-delete-downloads-folder');describe('delete downloads folder before each', () => {
deleteDownloadsFolderBeforeEach()it('should work', () => {})
})
``````javascript
const { deleteDownloadsFolderAfterAll } = require('cypress-delete-downloads-folder');describe('delete downloads folder after all', () => {
deleteDownloadsFolderAfterAll()it('should work', () => {})
})
``````javascript
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:
```json
{
"compilerOptions": {
"types": ["cypress", "cypress-delete-downloads-folder"]
}
}
```## Author
Yevhen Laichenkov
## License
[MIT](LICENSE)