Skip to content

Commit ff35fc5

Browse files
committed
Correct Playwright Output Directory #7260
1 parent e527632 commit ff35fc5

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Ticket: Correct Playwright Output Directory
2+
3+
GH ticket id: #7260
4+
5+
**Assignee:** Gemini
6+
**Status:** Done
7+
8+
## Description
9+
10+
The Playwright test runner was incorrectly creating a `test-results` directory at the project root, instead of within the `test/playwright` directory as intended.
11+
12+
## Resolution
13+
14+
1. The `playwright.config.mjs` file was modified to use absolute paths for `testDir` and `outputDir`. This was achieved by using Node.js's `path` and `url` modules to ensure the paths are always resolved correctly, regardless of the directory from which the test command is run.
15+
2. The `test` script in `package.json` was updated to explicitly specify the path to the configuration file using the `-c` flag (`playwright test -c test/playwright/playwright.config.mjs`).
16+
17+
This combination ensures that all test artifacts are consistently and correctly placed in `test/playwright/test-results`.

test/playwright/playwright.config.mjs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { defineConfig } from '@playwright/test';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
27

38
/**
49
* @see https://playwright.dev/docs/test-configuration
510
*/
611
export default defineConfig({
7-
testDir: './unit',
8-
outputDir: 'test-results',
12+
testDir: path.join(__dirname, 'unit'),
13+
outputDir: path.join(__dirname, 'test-results'),
914
/* Run tests in files in parallel */
1015
fullyParallel: true,
1116
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -15,7 +20,7 @@ export default defineConfig({
1520
/* Opt out of parallel tests on CI. */
1621
workers: process.env.CI ? 1 : undefined,
1722
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
18-
reporter: [['json', { outputFile: 'test-results/test-results.json' }]],
23+
reporter: [['json', { outputFile: path.join(__dirname, 'test-results/test-results.json') }]],
1924
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2025
use: {
2126
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */

0 commit comments

Comments
 (0)