I have few expand elements in my FAQ page, so I want to test all of them.
When writing my fixture and/or test in foreach
section, terminal reflects an error
ERROR no test to run.
I don't understand why
I tried to wrap the only test in foreach
and all fixture with the test, the result is the same.
fixture('check FAQ expand items').page(URL.local.faq)//.meta({ status: 'indev' })
.beforeEach(async () => {await waitForReact();
})
.before(async t => {
await waitForReact();
await list();
}).only;
faqItems.forEach( (element) => {
test(`check that ${element.getReact(({key})=>key)} is present`, async t => {
await t.expect(element.find('[expanded={true]]').exists).ok();
});
});
I expect test cafe will run faqItems.length
quantity of tests into 'check FAQ expand items' fixture
I run tests with command testcafe chrome faq.test.ts
screen shot of run test result
UPD
let faqItems: Array<Selector> = [faq.item];
async function list() {
const count = await faq.item.count;
console.log(`count = ${count}`)
for (let i = 0; i < count; i++) {
await faqItems.push( await faq.item.nth(i));
console.log(await faqItems[i].getReact(({key})=> key));
}
}
fixture('check FAQ expand items').page(URL.local.faq)//.meta({ status: 'indev' })
.beforeEach(async () => {
await waitForReact();
await list();
})
faqItems.forEach((element)=>{
test(`check that ${element.getReact(({key})=>key)} is present`, async t => {
await t.expect(element.find('[expanded={true}]').exists).ok();
});
})
The problem was that array initialized empty. I don't know why but into test array contains initialized data instead of generated in "BeforeAll". It seems like a testcafe bug, but maybe I am too junior to understand root cause. p.s. by the way it does not matter where is fixture inside/outside loop.