Skip to content

Commit caa1e64

Browse files
committed
test: More e2e debugging
1 parent 6b78247 commit caa1e64

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default defineConfig({
1212
},
1313
expect: {
1414
toHaveScreenshot: {
15+
scale: 'device',
1516
stylePath: 'test/e2e/screenshot.css',
1617
},
1718
},

test/e2e/fixtures.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export const test = baseTest.extend<{
1313
async context({}, use) {
1414
const extensionPath = path.join(__dirname, '../../dist');
1515
const context = await chromium.launchPersistentContext('', {
16-
headless: false,
16+
// headless: false,
1717
args: [
18-
// '--headless=new', // chromium 112+
18+
'--headless=new', // chromium 112+
1919
// '--virtual-time-budget=5000', // chromium 112+, fast-forward timers
2020
`--disable-extensions-except=${extensionPath}`,
2121
`--load-extension=${extensionPath}`,

test/e2e/newtab.spec.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import { expect, test } from './fixtures';
2020
// - No external requests
2121

2222
test('newtab page', async ({ page, extensionId }) => {
23+
await page.addInitScript(() => {
24+
const style = document.createElement('style');
25+
style.textContent = "body { font-family: 'Noto Sans', Arial, sans-serif !important; }";
26+
document.head.appendChild(style);
27+
});
28+
2329
await page.goto(`chrome-extension://${extensionId}/newtab.html`);
2430

2531
await expect(page).toHaveTitle('New Tab');
@@ -50,17 +56,20 @@ test('newtab page', async ({ page, extensionId }) => {
5056

5157
// TODO: More and better assertions.
5258

53-
// console.log('Body font family:', getComputedStyle(document.body).fontFamily);
59+
// FIXME: Remove!!!!!!!
5460
const fontFamily = await page.evaluate(() => getComputedStyle(document.body).fontFamily);
5561
console.log('Body font family:', fontFamily);
5662
});
5763

5864
test('matches screenshot', async ({ page, extensionId }) => {
59-
await page.goto(`chrome-extension://${extensionId}/newtab.html`);
60-
// await expect(page).toHaveScreenshot('newtab-default.png', { fullPage: true });
61-
await expect(page).toHaveScreenshot('newtab-default.png', {
62-
stylePath: ['test/e2e/screenshot.css'],
65+
await page.addInitScript(() => {
66+
const style = document.createElement('style');
67+
style.textContent = "body { font-family: 'Noto Sans', Arial, sans-serif !important; }";
68+
document.head.appendChild(style);
6369
});
70+
71+
await page.goto(`chrome-extension://${extensionId}/newtab.html`);
72+
await expect(page).toHaveScreenshot('newtab-default.png', { fullPage: true });
6473
});
6574

6675
test('has no console calls or unhandled errors', async ({ page, extensionId }) => {

test/e2e/screenshot.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/* font-family: Cantarell, Arial, sans-serif !important; */
21
body {
3-
color: blue !important;
42
font-family: 'Noto Sans', Arial, sans-serif !important;
5-
background: red !important;
6-
}
7-
8-
*,
9-
*::before,
10-
*::after {
11-
border: 1px solid green !important;
123
}

test/e2e/settings.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ test('settings page', async ({ page, extensionId }) => {
1515
await expect(labels[1]).toHaveText('Show bookmarks bar');
1616
await expect(labels[2]).toHaveText('Sections');
1717
await expect(labels[3]).toHaveText('Reset');
18+
19+
// FIXME: Remove!!!!!!!
20+
const fontFamily = await page.evaluate(() => getComputedStyle(document.body).fontFamily);
21+
console.log('Body font family:', fontFamily);
1822
});
1923

2024
test('matches screenshot', async ({ page, extensionId }) => {
2125
await page.goto(`chrome-extension://${extensionId}/settings.html`);
22-
// await expect(page).toHaveScreenshot('settings-default.png', { fullPage: true });
23-
await expect(page).toHaveScreenshot('settings-default.png');
26+
await expect(page).toHaveScreenshot('settings-default.png', { fullPage: true });
2427
});
2528

2629
test('has no console calls or unhandled errors', async ({ page, extensionId }) => {

0 commit comments

Comments
 (0)