Closed ajhoddinott closed 2 years ago
Hey, thanks a lot for the PR. Idea is awesome, I can also extend it later on for other commands. For this one I would just like to change 'noThrow' name to something that points better at what it does, like 'failSilently', 'continueOnError', or smth like that. Please also rename the added test titles to 'Should not fail creating/dropping...'
Thanks for the quick response and feedback. I’ll go with 'failSilently'.
I thought I’d add this to README.md at the bottom of the Usage section, or would you rather I left that to you?
createCollection
and dropCollection
have the option to failSilently
.
cy.createCollection('existing_collection', { failSilently: true}).then(res => {
cy.log(res); // Error object if collection already exists
});
cy.dropCollection('nonexistent_collection', { failSilently: true}).then(res => {
cy.log(res); // Error object if collection doesn’t exist
});
Feel free to add that to the readme file as well, thanks
Merged and released to npm
. Thanks a lot for your contribution :) Happy testing!
Feature request/suggestion in the form of a proof-of-concept PR.
Motivation: I want to be able to clear collection(s) before testing, to ensure a consistent state.
The errors might be caught and discarded with
cy.on('fail',
but it means adding boilerplate to distinguish between expected and unexpected failures in each test, or maybe wrapping the commands in support/index.js.This PR allows for:
The methodology might be extended to the validate() errors and other commands, but my immediate need is for dropCollection when the collection doesn’t exist.