Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ node_modules
playwright-report
test-results
log/
package-lock.json
./package-lock.json
local.log
112 changes: 112 additions & 0 deletions moduleA/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
const { expect, test } = require('@playwright/test');

let page;
const baseUrl = 'https://the-internet.herokuapp.com/';

test.beforeAll(async ({ browser }) => {
page = await browser.newPage();

await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('The Internet');

// await page.getByRole('link', { name: 'Checkboxes' }).click();

// const checkbox1 = page.getByRole('checkbox').first();
// const checkbox2 = page.getByRole('checkbox').last();

// expect(await checkbox1.isChecked()).toBe(false);
// await checkbox1.check();
// expect(await checkbox1.isChecked()).toBe(true);

// expect(await checkbox2.isChecked()).toBe(true);
// await checkbox2.uncheck();
// expect(await checkbox2.isChecked()).toBe(false);

// await page.goto(baseUrl);
// await page.getByRole('link', { name: 'Dropdown' }).click();

// const dropdown = page.locator('#dropdown');
// await dropdown.selectOption({ label: 'Option 1' });

// await page.goBack();
});

test('flaky test - intermittently passes and fails', async () => {
const headingName = Math.random() > 0.7 ? 'Available Examples' : 'Some Other Heading';
const availableExamples = page.getByRole('heading', { name: headingName });
const headingText = await availableExamples.textContent();
expect(headingText).toContain('Available Examples');
});

// test('always failing test - incorrect page title', async () => {
// await page.goto(baseUrl);

// await page.waitForTimeout(3000);

// await expect(page).toHaveTitle('Wrong title');
// });

test('always failing test - same stacktrace 1', async () => {
throw new Error("NullPointerError: Cannot read property 'foo' of null");
});

// test('always failing test - same stacktrace 2', async () => {
// throw new Error("NullPointerError: Cannot read property 'foo' of null");
// });

test('always pasing test - example F', async () => {
expect(true).toBe(true);
});

test('always pasing test - example G', async () => {
expect(true).toBe(true);
});

test('always pasing test - example H', async () => {
expect(true).toBe(true);
});

test('always pasing test - example I', async () => {
expect(true).toBe(true);
});

test('always passing test - verify page title', async () => {
await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('The Internet');
})

test.describe(() => {
test.describe.configure({ retries: 2 });

test('Test with framework-level retry - 2 retries configured', async () => {
const randomOutcome = Math.random() > 0.7; // 30% chance of passing
if (!randomOutcome) {
throw new Error("Test failed, retrying...");
}
});
});

// test.describe(() => {
// test.describe.configure({ retries: 2 });

// test('Another Test with framework-level retry - 2 retries configured', async () => {
// const randomOutcome = Math.random() > 0.7; // 30% chance of passing
// if (!randomOutcome) {
// throw new Error("Test failed, retrying...");
// }
// });
// });

test('always pasing test - example A', async () => {
expect(true).toBe(true);
});

test.afterAll(async () => {
await page.close();
});
116 changes: 116 additions & 0 deletions moduleB/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const { expect, test } = require('@playwright/test');

let page;
const baseUrl = 'https://the-internet.herokuapp.com/';

test.beforeAll(async ({ browser }) => {
page = await browser.newPage();

await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('The Internet');

// await page.getByRole('link', { name: 'Checkboxes' }).click();

// const checkbox1 = page.getByRole('checkbox').first();
// const checkbox2 = page.getByRole('checkbox').last();

// expect(await checkbox1.isChecked()).toBe(false);
// await checkbox1.check();
// expect(await checkbox1.isChecked()).toBe(true);

// expect(await checkbox2.isChecked()).toBe(true);
// await checkbox2.uncheck();
// expect(await checkbox2.isChecked()).toBe(false);

// await page.goto(baseUrl);
// await page.getByRole('link', { name: 'Dropdown' }).click();

// const dropdown = page.locator('#dropdown');
// await dropdown.selectOption({ label: 'Option 1' });

// await page.goBack();
});

test('flaky test - intermittently passes and fails', async () => {
const headingName = Math.random() > 0.7 ? 'Available Examples' : 'Some Other Heading';
const availableExamples = page.getByRole('heading', { name: headingName });
const headingText = await availableExamples.textContent();
expect(headingText).toContain('Available Examples');
});

// test('always failing test - same stacktrace 1', async () => {
// throw new Error("NullPointerError: Cannot read property 'foo' of null");
// });

test('always failing test - same stacktrace 2', async () => {
throw new Error("NullPointerError: Cannot read property 'foo' of null");
});

test('always pasing test - example F', async () => {
expect(true).toBe(true);
});

test('always pasing test - example G', async () => {
expect(true).toBe(true);
});

// test('always pasing test - example H', async () => {
// expect(true).toBe(true);
// });

test('always pasing test - example I', async () => {
expect(true).toBe(true);
});

test('always passing test - verify page title', async () => {
await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('The Internet');
})

test('always pasing test - example B', async () => {
expect(true).toBe(true);
});

test('always pasing test - example C', async () => {
expect(true).toBe(true);
});

test('always pasing test - example D', async () => {
expect(true).toBe(true);
});

test('always pasing test - example E', async () => {
expect(true).toBe(true);
});

test.describe(() => {
test.describe.configure({ retries: 2 });

test('Test with framework-level retry - 2 retries configured', async () => {
const randomOutcome = Math.random() > 0.7; // 30% chance of passing
if (!randomOutcome) {
throw new Error("Test failed, retrying...");
}
});
});

// test.describe(() => {
// test.describe.configure({ retries: 2 });

// test('Another Test with framework-level retry - 2 retries configured', async () => {
// const randomOutcome = Math.random() > 0.7; // 30% chance of passing
// if (!randomOutcome) {
// throw new Error("Test failed, retrying...");
// }
// });
// });

test.afterAll(async () => {
await page.close();
});
108 changes: 108 additions & 0 deletions moduleC/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const { expect, test } = require('@playwright/test');

let page;
const baseUrl = 'https://the-internet.herokuapp.com/';

test.beforeAll(async ({ browser }) => {
page = await browser.newPage();

await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('The Internet');

// await page.getByRole('link', { name: 'Checkboxes' }).click();

// const checkbox1 = page.getByRole('checkbox').first();
// const checkbox2 = page.getByRole('checkbox').last();

// expect(await checkbox1.isChecked()).toBe(false);
// await checkbox1.check();
// expect(await checkbox1.isChecked()).toBe(true);

// expect(await checkbox2.isChecked()).toBe(true);
// await checkbox2.uncheck();
// expect(await checkbox2.isChecked()).toBe(false);

// await page.goto(baseUrl);
// await page.getByRole('link', { name: 'Dropdown' }).click();

// const dropdown = page.locator('#dropdown');
// await dropdown.selectOption({ label: 'Option 1' });

// await page.goBack();
});

test('flaky test - intermittently passes and fails', async () => {
const headingName = Math.random() > 0.7 ? 'Available Examples' : 'Some Other Heading';
const availableExamples = page.getByRole('heading', { name: headingName });
const headingText = await availableExamples.textContent();
expect(headingText).toContain('Available Examples');
});

test('always failing test - incorrect page title', async () => {
await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('Wrong title');
});

test('always failing test - same stacktrace 1', async () => {
throw new Error("NullPointerError: Cannot read property 'foo' of null");
});

// test('always failing test - same stacktrace 2', async () => {
// throw new Error("NullPointerError: Cannot read property 'foo' of null");
// });

test('always pasing test - example F', async () => {
expect(true).toBe(true);
});

test('always pasing test - example G', async () => {
expect(true).toBe(true);
});

// test('always pasing test - example H', async () => {
// expect(true).toBe(true);
// });

test('always pasing test - example I', async () => {
expect(true).toBe(true);
});

test('always passing test - verify page title', async () => {
await page.goto(baseUrl);

await page.waitForTimeout(3000);

await expect(page).toHaveTitle('The Internet');
})

test.describe(() => {
test.describe.configure({ retries: 2 });

test('Test with framework-level retry - 2 retries configured', async () => {
const randomOutcome = Math.random() > 0.7; // 30% chance of passing
if (!randomOutcome) {
throw new Error("Test failed, retrying...");
}
});
});

// test.describe(() => {
// test.describe.configure({ retries: 2 });

// test('Another Test with framework-level retry - 2 retries configured', async () => {
// const randomOutcome = Math.random() > 0.7; // 30% chance of passing
// if (!randomOutcome) {
// throw new Error("Test failed, retrying...");
// }
// });
// });

test.afterAll(async () => {
await page.close();
});
6 changes: 3 additions & 3 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// This is a sample config for what users might be running locally
const config = {
testDir: './tests',
testMatch: '**/bstack_test*.js',
testDir: './',
testMatch: 'module*/**/*.js',

/* Maximum time one test can run for. */
timeout: 90 * 1000,
timeout: 10 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
Expand Down