-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Test not found error when using async/await calls to fetch data #9636
Comments
@pavelfeldman As discussed I have raise this issue to track the feasibility with respect to playwright-test. |
We've discussed async describes and decided to not support them for now. Workaround #1. Instead of multiple tests, use multiple steps. test(`Testing multiple urls`, async ({ page }) => {
const urlList = await sample.getUrlList();
for (const url of urlList) {
await test.step(`testing url: ${url}`, async () => {
await page.goto(url);
// ...
});
}
}); Workaround #2. Prepare data in global setup and store it in the file. Read from the file (synchronously) in // global-setup.js
export default async function() {
const urlList = await sample.getUrlList();
fs.writeFileSync('./urls.json', JSON.stringify(urlList), 'utf-8');
};
//example.spec.js
test.describe('Test suite 1', async () => {
const urlList = require('./urls.json');
urlList.forEach((url) => {
test(`Testing URL: ${url}`, async ({ page }) => {
await page.goto(url);
});
});
}); |
Hey @dgozman is this still the behaviour of describe? Does not work with async? Sorry to bother here, didnt want to file a new issue just for this! Thank you! |
@imartinflores Yes, this has not changed, |
Thanks a lot! |
Context:
Describe the bug
My use case is a simple data driven scenario. Where I am using async/await calls when reading data sets under
test.describe
its not able to identify thetest
available. Maybe becausetest.describe
can not beasync
. Gettingno tests found
response when executing my test file.============================================
Even if I don't use
test.describe
as async and move my fetching dataset logic totest.beforeAll
hook then also its not working.. Maybe the reason is that its not looking for thetest
inside the loop i.e.urlList.forEach
. Getting no tests found response when executing my test file.The text was updated successfully, but these errors were encountered: