Taking this fixture I would like to set the checkoutId
based on the result from the API call in the before
fixture hook so I can use it to set the page on my tests
let checkoutId;
fixture`Check out as guest user`
.page`localhost:3001/checkout/start/${checkoutId}`
.before(async () => {
await checkout.getCheckoutId(sampleData.cart)
.then(id => (checkoutId = id));
});
// and here the rest of my tests based on the page
I tried fixture hooks, sharing variables but I can't get it to work, checkoutId is undefined when requesting the page.
Is this scenario even possible?
While TestCafe does not support dynamic URLs, you can call the t.navigateTo(url) action inside "before" based on your condition.
You can do in this way:
const TEST_URL = "www.someurl.com"
fixture`jtc-b2c.testcafe`.page(TEST_URL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With