1

Is there a way to do an IF condition on the metadata in the test script? For e.g

test.meta({ tablet: ‘true’, portrait: 'false', landscape: 'true' })(‘L0 | Tablet device’, async t => {
    // Verify component exists in portrait and landscape mode
    await t.expect(abc).ok();

    // Verify component exists in landscape mode only
    if (t.metadata.landscape == 'true') {
    ...... 
    }
});
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47

1 Answers1

2

You can get the meta inside a test using the following code:

t.testRun.test.meta

However, I need to note that it's not a documented API, and it can be changed in the future, so you need to use it carefully.

I think in your case, the best solution will be something like this:

const isTablet = true;

test.meta({ tablet: isTablet })(‘L0 | Tablet device’, async t => {
    if (isTablet) {
    ...... 
    }
});
Alex Kamaev
  • 6,198
  • 1
  • 14
  • 29