Skip to content

Commit

Permalink
Fixed tests failing when ran together, now run in sequence.
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent T <[email protected]>
  • Loading branch information
vyncent-t committed Aug 7, 2024
1 parent 48d298f commit 0ed628b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 37 deletions.
42 changes: 12 additions & 30 deletions app/app-e2e-tests/e2e/tests/demo-test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { test } from '@playwright/test';
import { _electron } from '@playwright/test';
import {test } from '@playwright/test';
import { _electron, ElectronApplication, Page } from 'playwright';
import { headlampAppPage } from './demo-test';

const electron = _electron;
let electronApp;
let electronApp: ElectronApplication;
let page: Page;

test.beforeAll(async () => {
// Launch Electron app.
Expand All @@ -12,41 +13,22 @@ test.beforeAll(async () => {
timeout: 0,
args: ['main.js'],
});
});

test('launch app / check homepage', async () => {
// Launch Electron app.
// Get the first window.
page = await electronApp.firstWindow();
});

// note: may use .context() instead of .firstWindow()?
// const context = await electronApp.context();
test.afterAll(async () => {
// Close the Electron app.
await electronApp.close();
});

// note: firstWindow returns a page object so we can replace the window object
const page = await electronApp.firstWindow();
test('launch app / check homepage', async () => {
const headlampPage = new headlampAppPage(page);

await headlampPage.navHomepage();

electronApp.close();
// electronApp.on('window', async () => {
// await headlampPage.homepage();
// });
});

test('launch app / check notifications', async () => {
// Launch Electron app.
// const electronApp = await electron.launch({
// cwd: '/home/vtaylor/headlamp/app/electron',
// timeout: 0,
// args: ['main.js'],
// });

const page = await electronApp.firstWindow();
const headlampPage = new headlampAppPage(page);

await headlampPage.navNotifactions();

electronApp.close();
// electronApp.on('window', async () => {
// await headlampPage.notifications();
// });
});
2 changes: 0 additions & 2 deletions app/app-e2e-tests/e2e/tests/demo-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ export class headlampAppPage {
constructor(private page: Page) {}

async navHomepage() {
await this.page.waitForLoadState('domcontentloaded');
await this.page.goto('http://localhost:3000/');

await expect(this.page.getByRole('button', { name: 'Home' })).toBeVisible();
await this.page.getByRole('button', { name: 'Home' }).click();
}

async navNotifactions() {
await this.page.waitForLoadState('domcontentloaded');
await this.page.goto('http://localhost:3000/');

await expect(this.page.getByRole('button', { name: 'Notifications' })).toBeVisible();
Expand Down
16 changes: 11 additions & 5 deletions app/app-e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from '@playwright/test';
import { defineConfig } from '@playwright/test';

/**
* Read environment variables from file.
Expand All @@ -17,13 +17,13 @@ export default defineConfig({
timeout: 60000,
},
/* Run tests in files in parallel */
fullyParallel: true,
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: 1,
/* 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 All @@ -40,9 +40,15 @@ export default defineConfig({
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: 'electron',
use: {
browserName: 'chromium',
},
},
// {
// name: 'chromium',
// use: { ...devices['Desktop Chrome'] },
// },

// {
// name: 'firefox',
Expand Down

0 comments on commit 0ed628b

Please sign in to comment.