cypress-io / cypress-skip-test

Simple commands to skip a test based on platform, browser or a url
MIT License
180 stars 10 forks source link

boolean flag not working when flag is not an expression #172

Open penchef opened 2 years ago

penchef commented 2 years ago

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', () => {
            ...
          });
   });
});