Skip to content

Commit 167c836

Browse files
committed
test: update
1 parent 9f2358e commit 167c836

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/e2e/fixtures/baseTest.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,18 @@ export const test = base.extend<TestFixtures>({
5555
const vscodeDir = path.join(projectDir, ".vscode");
5656
fs.ensureDirSync(vscodeDir);
5757
const settingsPath = path.join(vscodeDir, "settings.json");
58-
const existingSettings = fs.existsSync(settingsPath)
59-
? JSON.parse(fs.readFileSync(settingsPath, "utf-8"))
60-
: {};
58+
let existingSettings: Record<string, unknown> = {};
59+
if (fs.existsSync(settingsPath)) {
60+
// settings.json may contain JS-style comments (JSONC), strip them before parsing
61+
const raw = fs.readFileSync(settingsPath, "utf-8");
62+
const stripped = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
63+
try {
64+
existingSettings = JSON.parse(stripped);
65+
} catch {
66+
// If still invalid, start fresh — our injected settings are more important
67+
existingSettings = {};
68+
}
69+
}
6170
const mergedSettings = {
6271
...existingSettings,
6372
"telemetry.telemetryLevel": "off",

0 commit comments

Comments
 (0)