Skip to content

Commit 2c310fc

Browse files
committed
Updated setup.ts file not to use path aliases, using relative imports
1 parent 0d381e8 commit 2c310fc

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

tests/setup.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
import { test as base, expect, type Page, type TestInfo } from '@playwright/test';
2-
import { logger } from '../utils/logger';
1+
/**
2+
* Custom Playwright test setup.
3+
*
4+
* This file exports a customized `test` and `expect` for use in all test files.
5+
* It wraps Playwright's base test to add common hooks, logging, and shared fixtures.
6+
*
7+
* Usage:
8+
* Import `test` and `expect` from this file in your test specs using a relative path:
9+
* import { test, expect } from '../setup';
10+
*
11+
* Why not use a path alias?
12+
* Playwright and Node.js do not resolve TypeScript path aliases at runtime by default.
13+
* Using relative imports ensures compatibility in all environments.
14+
*
15+
* Contributors:
16+
* - Add shared hooks, fixtures, or logging here to apply them across all tests.
17+
* - Do not import `@playwright/test` directly in your test files—use this setup instead.
18+
*/
319

4-
base.beforeEach(async ({ page }, testInfo) => {
5-
logger.info(`🚀 Starting test: ${testInfo.title}`);
6-
logger.info(`🔖 Tags: ${testInfo.annotations.map(a => a.type).join(', ') || 'None'}`);
7-
});
20+
import { test as base, expect } from '@playwright/test';
21+
import { logger } from '../utils/logger';
822

23+
// Example: Add a global afterEach hook for logging
924
base.afterEach(async ({ page }, testInfo) => {
1025
const status = testInfo.status?.toUpperCase();
1126
const duration = `${testInfo.duration}ms`;
@@ -20,4 +35,4 @@ base.afterEach(async ({ page }, testInfo) => {
2035
});
2136

2237
export const test = base;
23-
export { expect };
38+
export { expect };

0 commit comments

Comments
 (0)