Last active
October 21, 2021 00:19
-
-
Save UberMouse/facbe751c3ecb9b31e8b4f6221567b7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Fixtures } from "@playwright/test"; | |
import { test as base } from "@playwright/test"; | |
import { BrowserContext, ElectronApplication, Page } from "playwright"; | |
export { expect } from "@playwright/test"; | |
type ElectronTestFixtures = { | |
electronApp: ElectronApplication; | |
page: Page; | |
context: BrowserContext; | |
}; | |
export const electronFixtures: Fixtures<ElectronTestFixtures> = { | |
electronApp: async ({}, run) => { | |
// This env prevents 'Electron Security Policy' console message. | |
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = "true"; | |
const electronApp = await aFunctionThatCallsElectronLaunchProcess(); | |
await run(electronApp); | |
await electronApp.close(); | |
}, | |
page: async ({ electronApp }, run) => { | |
const page = await electronApp.firstWindow(); | |
await run(page); | |
}, | |
context: async ({ electronApp }, run) => { | |
const context = electronApp.context(); | |
await run(context); | |
}, | |
}; | |
// @ts-ignore some error about a string type now having `undefined` as part of it's union | |
export const electronTest = base.extend<ElectronTestFixtures>(electronFixtures); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { PlaywrightTestConfig } from '@playwright/test'; | |
import * as path from 'path'; | |
const outputDir = path.join(__dirname, 'test-results'); | |
const config: PlaywrightTestConfig = { | |
outputDir, | |
timeout: 30000, | |
globalTimeout: 5400000, | |
workers: process.env.CI ? 1 : undefined, | |
forbidOnly: !!process.env.CI, | |
preserveOutput: process.env.CI ? 'failures-only' : 'always', | |
retries: process.env.CI ? 3 : 1, | |
reporter: process.env.CI ? [ | |
[ 'dot' ], | |
[ 'json', { outputFile: path.join(outputDir, 'report.json') } ], | |
] : 'line', | |
projects: [{ | |
name: 'chromium', | |
use: { | |
browserName: 'chromium', | |
trace: process.env.CI ? 'on-first-retry' : 'on' | |
}, | |
metadata: { | |
platform: process.platform, | |
headful: true, | |
browserName: 'electron', | |
channel: undefined, | |
mode: 'default', | |
video: false, | |
} | |
}], | |
}; | |
export default config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment