lint
This commit is contained in:
1 parent
fc250c54ed
commit
5eec516459
62 files changed
+3912
-3376
No files matched your search
+16
-16
@@ -1,40 +1,40 @@
|
||||
import { Page } from 'playwright'
|
||||
import { TestInfo } from 'playwright/test'
|
||||
import type { Page } from 'playwright';
|
||||
import type { TestInfo } from 'playwright/test';
|
||||
|
||||
export default class TestUtil {
|
||||
_page: Page
|
||||
_page: Page;
|
||||
|
||||
_testInfo: TestInfo
|
||||
_testInfo: TestInfo;
|
||||
|
||||
_testScreenshotPath: string
|
||||
_testScreenshotPath: string;
|
||||
|
||||
constructor(page: Page, testInfo: TestInfo, testScreenshotPath: string) {
|
||||
this._page = page
|
||||
this._testInfo = testInfo
|
||||
this._testScreenshotPath = testScreenshotPath
|
||||
this._page = page;
|
||||
this._testInfo = testInfo;
|
||||
this._testScreenshotPath = testScreenshotPath;
|
||||
}
|
||||
|
||||
async captureScreenshot(pageInstance: Page, screenshotName: string) {
|
||||
if (!pageInstance) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const screenshotPath = `${this._testScreenshotPath}/${screenshotName || `unknown_${Date.now()}`}.png`
|
||||
const screenshotPath = `${this._testScreenshotPath}/${screenshotName || `unknown_${Date.now()}`}.png`;
|
||||
|
||||
await pageInstance.screenshot({ path: screenshotPath })
|
||||
await pageInstance.screenshot({ path: screenshotPath });
|
||||
} catch {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
async onTestError(error: Error) {
|
||||
const titleLists = [...this._testInfo.titlePath]
|
||||
titleLists.shift()
|
||||
const title = titleLists.join('-')
|
||||
const titleLists = [...this._testInfo.titlePath];
|
||||
titleLists.shift();
|
||||
const title = titleLists.join('-');
|
||||
|
||||
await this.captureScreenshot(this._page, `${title}_${Date.now()}`)
|
||||
await this.captureScreenshot(this._page, `${title}_${Date.now()}`);
|
||||
|
||||
return new Error(error.message)
|
||||
return new Error(error.message);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user