I have a few tests that only need to be run when in a mobile browser. Currently I have a client function to check the user agent.
const checkMobile = ClientFunction(() => /iPhone|Android/i.test(navigator.userAgent))
Which I then access inside my tests:
test("Check if mobile", async t => {
const isMobile = await checkMobile();
if (isMobile) {
await t
// do the tests
}
}
Is there a way for me to use this in a fixture? Like a fixture which will only run if checkMobile is true? So I don't need to repeat this check in every test manually. I'm sure there's a smarter way to go about it than what I have right now. I tried doing the check in the fixture's beforeEach hook but it didn't work out for me to then try to share the outcome of that in a variable to pass down to the tests.