For tests that run locally but fail without slow mo or waitForLoadState, is it better to user slow mo or use the below waits?
Just to note, I use locators in all my tests.
await page.waitForLoadState('domcontentloaded', { timeout: 15000 });
await page.waitForLoadState('load', { timeout: 30000 });
await page.waitForLoadState('networkidle', { timeout: 5000 });
This thread is trying to answer question "For tests that run locally but fail without slow mo or waitForLoadState, is it better to use slow mo or the below waits?"
we absolutely discourage both. To be able to assist you we need to know how your tests look like, what the errors are etc. Also make sure to follow our best practises: https://playwright.dev/docs/best-practices
Here is a portion of my tests. I am not using live data but mocks for the api calls.
it('should display the total patients number requiring rec', async ({ page }) => {
const el = page.getByText('15 patients require reconcillation');
expect(el).toBeVisible();
});
describe('When viewing tables', function() {
it('should have columns', async ({ page }) => {
const el = page.getByRole('columnheader');
const text = ['EMR MRN', 'Name', 'DOB', 'Gender', 'Address', 'Match'];
expect(el).toHaveText(text);
});
it('should have rows', async ({ page }) => {
const el = page.locator('tr');
// 2 rows + header row
expect(el).toHaveCount(3);
});
it('should show patient data', async ({ page }) => {
const el = page.getByRole('cell');
const text = [
'',
'12/13/1935',
'female',
'5 Balling Hill Ave, Beltsville MD, 12324',
'Match',
'999999',
'Doe, John',
'12/7/1900',
'male',
'',
'Match',
];
expect(el).toHaveText(text);
});
See here how to prevent this during linting: https://playwright.dev/docs/best-practices#lint-your-tests
I am using .mjs files.... will https://typescript-eslint.io/rules/no-floating-promises work on .mjs files?
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].