openspec-playwright 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
## What's Changed
|
|
2
2
|
|
|
3
|
-
- fix:
|
|
3
|
+
- fix: playwright.config.ts detects package.json in subdirectories
|
|
4
4
|
|
|
5
|
-
**Full Changelog**: https://github.com/wxhou/openspec-playwright/releases/tag/v0.1.
|
|
5
|
+
**Full Changelog**: https://github.com/wxhou/openspec-playwright/releases/tag/v0.1.24
|
|
@@ -2,8 +2,22 @@ import { defineConfig, devices } from '@playwright/test';
|
|
|
2
2
|
import { readFileSync, existsSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
|
|
5
|
+
// ─── Detect project root (find package.json walking up) ───
|
|
6
|
+
function findProjectRoot(start: string): string {
|
|
7
|
+
let dir = start;
|
|
8
|
+
for (let i = 0; i < 10; i++) {
|
|
9
|
+
if (existsSync(join(dir, 'package.json'))) return dir;
|
|
10
|
+
const parent = join(dir, '..');
|
|
11
|
+
if (parent === dir) break;
|
|
12
|
+
dir = parent;
|
|
13
|
+
}
|
|
14
|
+
return start;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const projectRoot = findProjectRoot(__dirname);
|
|
18
|
+
|
|
5
19
|
// ─── BASE_URL: prefer env, then seed.spec.ts, then default ───
|
|
6
|
-
const seedSpec = join(
|
|
20
|
+
const seedSpec = join(projectRoot, 'tests', 'playwright', 'seed.spec.ts');
|
|
7
21
|
let baseUrl = process.env.BASE_URL || 'http://localhost:3000';
|
|
8
22
|
if (existsSync(seedSpec)) {
|
|
9
23
|
const content = readFileSync(seedSpec, 'utf-8');
|
|
@@ -12,19 +26,17 @@ if (existsSync(seedSpec)) {
|
|
|
12
26
|
}
|
|
13
27
|
|
|
14
28
|
// ─── Dev command: detect from package.json scripts ───
|
|
15
|
-
const pkgPath = join(
|
|
29
|
+
const pkgPath = join(projectRoot, 'package.json');
|
|
16
30
|
let devCmd = 'npm run dev';
|
|
17
31
|
if (existsSync(pkgPath)) {
|
|
18
32
|
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
19
33
|
const scripts = pkg.scripts ?? {};
|
|
20
|
-
// Prefer in order: dev, start, serve, preview
|
|
21
34
|
devCmd = scripts.dev ?? scripts.start ?? scripts.serve ?? scripts.preview ?? devCmd;
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
export default defineConfig({
|
|
25
|
-
testDir: '
|
|
26
|
-
|
|
27
|
-
outputDir: '../tests/playwright/test-results',
|
|
38
|
+
testDir: join(projectRoot, 'tests', 'playwright'),
|
|
39
|
+
outputDir: join(projectRoot, 'tests', 'playwright', 'test-results'),
|
|
28
40
|
fullyParallel: true,
|
|
29
41
|
forbidOnly: !!process.env.CI,
|
|
30
42
|
retries: process.env.CI ? 2 : 0,
|
|
Binary file
|