cypress chai avoid printing the value

Viewed 206

I am using expect to assert a string but it prints the value.
Below is the code

expect(USER).to.be.a('string').and.to.not.be.empty;

and this is how it prints in the cypress: enter image description here

How should I avoid printing the value?

2 Answers

Cypress modifies chai.expect but does not seem to add a way to turn off logging.

If you import from node_modules you can run the original and avoid the log.

const chai = require('chai');

it('expects witout log', () => {
  chai.expect(USER).to.be.a('string').and.to.not.be.empty;  // no logging happening
})

Just modify the value in expect param. For example:

expect(USER.length).to.be.greaterThan(1)
Related