Skip to content

Commit e052a29

Browse files
committed
refactor: ♻️ replace JSON.stringify with serialize-javascript for function support in configuration
This commit swaps out JSON.stringify in favor of serialize-javascript, allowing for function support within configuration.
1 parent 87cddae commit e052a29

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@
4343
"@playwright/test": "^1.34.3",
4444
"commander": "^10.0.1",
4545
"mountebank": "^2.8.2",
46+
"serialize-javascript": "^6.0.1",
4647
"typescript": "^5.0.4"
4748
},
4849
"devDependencies": {
4950
"@types/node": "^20.2.3",
51+
"@types/serialize-javascript": "^5.0.2",
5052
"tsconfig-to-dual-package": "^1.2.0"
5153
}
5254
}

packages/core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as fs from 'fs/promises';
77
import { spawn } from 'child_process';
88
import { PlaywrightTestConfig } from '@playwright/test';
99
import { clearLine, cursorTo } from "readline";
10+
import serialize from 'serialize-javascript'
1011

1112
function curl(options: any, method: "POST" | "GET" | "PUT" | "DELETE", path: string, data: any) {
1213
return new Promise((resolve, reject) => {
@@ -114,7 +115,7 @@ async function startPlaywright({ tempDir, ...config }: PlaywrightTestConfig & {
114115
const configFile = path.join(tempDir, 'playwright.config.js');
115116

116117
await fs.writeFile(configFile, `import { defineConfig, devices } from "@playwright/test";
117-
export default defineConfig(${JSON.stringify(config, null, 2)});`);
118+
export default defineConfig(${serialize(config, { space: 2 })});`);
118119

119120
return new Promise((resolve) => {
120121
log(`Playwright: starting 🔄`);

pnpm-lock.yaml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)