Files
twenty/packages/twenty-e2e-testing/lib/fixtures/screenshot.ts
BOHEUS b1fbf4b683 E2E tests (#6717)
Continuation of #6644 

Now chromium browser is used in workspaces tests instead of firefox and
screenshots after each test are properly saved in one folder when run
from IDE and from terminal using `yarn test:e2e` command
2024-08-27 11:07:10 +02:00

33 lines
994 B
TypeScript

import { test as base } from '@playwright/test';
import path from 'path';
const date = new Date();
export const test = base.extend<{ screenshotHook: void }>({
screenshotHook: [
async ({ page, browserName }, use, workerInfo) => {
// here everything is the same as beforeEach()
// goto is to go to website as login setup saves the cookies of logged-in user, not the state of browser
await page.goto('/');
await use(); // here is the code of test
// here everything is the same as afterEach()
// automatic fixture of making screenshot after each test
await page.screenshot({
path: path.resolve(
__dirname,
'..',
'..',
'results',
'screenshots',
`${workerInfo.project.name}`,
browserName,
`${date.toISOString()}.png`,
),
});
},
{ auto: true }, // automatic fixture runs with every test
],
});
export { expect } from '@playwright/test';