-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fixtures for global aftereach and beforeeach hooks
- Loading branch information
Showing
4 changed files
with
62 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const debug = require('debug'); | ||
const fs = require('fs'); | ||
const { test: base, expect } = require('@playwright/test'); | ||
|
||
import { writeTestStatusToExcelFile } from '../utils/excelhandler'; | ||
|
||
const { RegistrationPage } = require('../pages/registrationpage'); | ||
const { LoginPage } = require('../pages/loginpage'); | ||
const { ParaBankHomePage } = require('../pages/parabankhomepage'); | ||
const { OpenNewAccountPage } = require('../pages/opennewaccountpage'); | ||
|
||
// Extend the base test to include a custom fixture | ||
const test = base.extend({ | ||
|
||
registrationPage: async ({ page }, use) => { | ||
const registrationPage = new RegistrationPage(page); | ||
await use(registrationPage); | ||
}, | ||
loginPage: async ({ page }, use) => { | ||
const loginPage = new LoginPage(page); | ||
await use(loginPage); | ||
}, | ||
paraBankHomePage: async ({ page }, use) => { | ||
const paraBankHomePage = new ParaBankHomePage(page); | ||
await use(paraBankHomePage); | ||
}, | ||
openNewAccountPage: async ({ page }, use) => { | ||
const openNewAccountPage = new OpenNewAccountPage(page); | ||
await use(openNewAccountPage); | ||
}, | ||
// Optionally, expose the raw page instance | ||
pageInstance: async ({ page }, use) => { | ||
await use(page); | ||
}, | ||
saveLogs: [async ({ }, use, testInfo) => { | ||
// Collecting logs during the test | ||
// const logs = []; | ||
// debug.log = (...args) => logs.push(args.map(String).join('')); | ||
// debug.enable('myserver'); | ||
await use(); | ||
|
||
// After the test, check whether the test passed or failed | ||
// if (testInfo.status !== testInfo.expectedStatus) { | ||
// // `outputPath()` API guarantees a unique file name | ||
// const logFile = testInfo.outputPath('logs.txt'); | ||
// await fs.promises.writeFile(logFile, logs.join('\n'), 'utf8'); | ||
// testInfo.attachments.push({ name: 'logs', contentType: 'text/plain', path: logFile }); | ||
// } | ||
await writeTestStatusToExcelFile(testInfo); | ||
}, { auto: true }], | ||
}); | ||
|
||
module.exports = { test, expect }; |
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
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
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