I am trying to parse a big file and assert that a string is not included in the file using cypress. I want to replace the assertion message to keep my log clean. I have tried this: I wraped the content as follow:
cy.task('parsePdf', filePath)
.its('text')
.then(($txt) => {
cy.wrap($txt).as('content');
});
Then I have tried to assert this using Chai expect and insert a custom message in two ways which both result the same:
First:
cy.get('@content').should(($txt) => {
expect($txt).to.not.include(
'text that should not be in the content',
'Custom error message'
);
});
Second:
cy.get('@content').should(($txt) => {
expect($txt, 'Custom error message').to.not.include(
'text that should not be in the content');
});
Result:
Custom error message expected Full report content to not include text that should not be in the content.
What I looking for is only logging Custom error message in a failure.
Expected:
Custom error message