fix: correctly use typescript in test
This commit is contained in:
1 parent
50af35dd52
commit
c7cd07af9f
2 files changed
+17
-8
No files matched your search
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
import * as base from '@playwright/test'
|
import * as base from '@playwright/test'
|
||||||
import { _electron as electron } from 'playwright'
|
import { _electron as electron, Page, ElectronApplication } from 'playwright'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { main } from '../package.json'
|
import { main } from '../package.json'
|
||||||
import TestUtil from './testUtil.mjs'
|
import TestUtil from './testUtil.mjs'
|
||||||
|
|
||||||
let appElectron
|
let appElectron: ElectronApplication
|
||||||
let page
|
let page: Page
|
||||||
|
|
||||||
const __cwd = process.cwd()
|
const __cwd = process.cwd()
|
||||||
const __isCiProcess = process.env.CI === 'true'
|
const __isCiProcess = process.env.CI === 'true'
|
||||||
@@ -52,7 +52,7 @@ export const beforeAll = async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await base.expect(evaluateResult.packaged, 'app is not packaged').toBe(false)
|
base.expect(evaluateResult.packaged, 'app is not packaged').toBe(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const afterAll = async () => {
|
export const afterAll = async () => {
|
||||||
|
|||||||
+13
-4
@@ -1,11 +1,20 @@
|
|||||||
|
import { Page } from 'playwright'
|
||||||
|
import { TestInfo } from 'playwright/test'
|
||||||
|
|
||||||
export default class TestUtil {
|
export default class TestUtil {
|
||||||
constructor(page, testInfo, testScreenshotPath) {
|
_page: Page
|
||||||
|
|
||||||
|
_testInfo: TestInfo
|
||||||
|
|
||||||
|
_testScreenshotPath: string
|
||||||
|
|
||||||
|
constructor(page: Page, testInfo: TestInfo, testScreenshotPath: string) {
|
||||||
this._page = page
|
this._page = page
|
||||||
this._testInfo = testInfo
|
this._testInfo = testInfo
|
||||||
this._testScreenshotPath = testScreenshotPath
|
this._testScreenshotPath = testScreenshotPath
|
||||||
}
|
}
|
||||||
|
|
||||||
async captureScreenshot(pageInstance, screenshotName) {
|
async captureScreenshot(pageInstance: Page, screenshotName: string) {
|
||||||
if (!pageInstance) {
|
if (!pageInstance) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -19,13 +28,13 @@ export default class TestUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onTestError(error) {
|
async onTestError(error: Error) {
|
||||||
const titleLists = [...this._testInfo.titlePath]
|
const titleLists = [...this._testInfo.titlePath]
|
||||||
titleLists.shift()
|
titleLists.shift()
|
||||||
const title = titleLists.join('-')
|
const title = titleLists.join('-')
|
||||||
|
|
||||||
await this.captureScreenshot(this._page, `${title}_${Date.now()}`)
|
await this.captureScreenshot(this._page, `${title}_${Date.now()}`)
|
||||||
|
|
||||||
return new Error(error)
|
return new Error(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user