Skip to content

Commit

Permalink
Budget more time for playwright tests & disable retries (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwillchen authored Jul 14, 2024
1 parent cdc2312 commit 0e0cb95
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
62 changes: 33 additions & 29 deletions mesop/tests/e2e/web_components/slot_test.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
import {test, expect, Page} from '@playwright/test';

test('web components - slot', async ({page}) => {
await page.goto('http://localhost:32123/web_component/slot/slot_app');
// Make sure the page has loaded:
expect(page.getByRole('button', {name: 'Decrement'})).toBeVisible();
test.describe(() => {
// All tests in this describe group will get 2 retry attempts.
test.describe.configure({retries: 2});
test('web components - slot', async ({page}) => {
await page.goto('http://localhost:32123/web_component/slot/slot_app');
// Make sure the page has loaded:
expect(page.getByRole('button', {name: 'Decrement'})).toBeVisible();

assertValue(10);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(11);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(12);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(11);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(10);
assertValue(10);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(11);
await page.getByRole('button', {name: 'increment'}).click();
assertValue(12);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(11);
await page.getByRole('button', {name: 'Decrement'}).click();
assertValue(10);

async function assertValue(value: number) {
// Check that the outer component is displaying the right value.
expect(
await page
.locator('div')
.filter({hasText: `Value: ${value} increment Start of`})
.textContent(),
).toContain(value.toString());
async function assertValue(value: number) {
// Check that the outer component is displaying the right value.
expect(
await page
.locator('div')
.filter({hasText: `Value: ${value} increment Start of`})
.textContent(),
).toContain(value.toString());

// Check that the inner component is displaying the right value.
expect(
await page
.locator('slot-counter-component')
.getByText('Value:')
.textContent(),
).toContain(value.toString());
}
// Check that the inner component is displaying the right value.
expect(
await page
.locator('slot-counter-component')
.getByText('Value:')
.textContent(),
).toContain(value.toString());
}
});
});
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {defineConfig, devices} from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
timeout: process.env.CI ? 30000 : 15000, // Budget more time for CI since tests run slower there.
timeout: process.env.CI ? 50000 : 25000, // Budget more time for CI since tests run slower there.
testDir: '.',
// Use a custom snapshot path template because Playwright's default
// is platform-specific which isn't necessary for Mesop e2e tests
Expand All @@ -24,7 +24,7 @@ export default defineConfig({
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
retries: 0,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down

0 comments on commit 0e0cb95

Please sign in to comment.