cypress-skip-test icon indicating copy to clipboard operation
cypress-skip-test copied to clipboard

boolean flag not working when flag is not an expression

Open penchef opened this issue 3 years ago • 0 comments

Ran into this little issue:

When:

const testUsers = [
  {
    username: 'Foo',
    testFeatureFoo: true,
  },
  {
    username: 'Bar',
  },
];

testUsers.forEach( (user) => { 
  onlyOn(user.testFeatureFoo, () => {                      // <<<<<<<<<<<<<<<<<<<<<<<
          it('testingFoo', () => {
            ...
          });
   });
});

Then: it results into

The following error originated from your test code, not from Cypress.

  > Invalid syntax: cy.onlyOn(<name>), for example cy.onlyOn("linux")
  

However this works:

const testUsers = [
  {
    username: 'Foo',
    testFeatureFoo: true,
  },
  {
    username: 'Bar',
  },
];

testUsers.forEach( (user) => { 
  onlyOn(user.testFeatureFoo === true, () => {                   // <<<<<<<<<<<<<<<<<<<<< alternativly: !!user.testFeatureFoo 
          it('testingFoo', () => {
            ...
          });
   });
});

penchef avatar Jan 10 '22 23:01 penchef