hbenl / vscode-mocha-test-adapter

Mocha Test Adapter for the VS Code Test Explorer
MIT License
91 stars 31 forks source link

`SyntaxError: Unexpected number in JSON` using `"VSCODE_LAUNCH_ARGS": "--disable-extensions"` #159

Closed carlocardella closed 3 years ago

carlocardella commented 3 years ago

Using VSCode Stable I want to start my tests without extensions loaded in the spawned Insiders version, I am using:

  "mochaExplorer.env": {
    "VSCODE_VERSION": "insiders",
    "ELECTRON_RUN_AS_NODE": null,
    "VSCODE_LAUNCH_ARGS": "--disable-extensions"
  },

But I am getting:

[2021-05-24 18:31:07.965] [INFO] Test Explorer found
[2021-05-24 18:31:07.965] [INFO] Creating adapter for c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample
[2021-05-24 18:31:07.966] [INFO] Registering adapter for c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample
[2021-05-24 18:31:07.967] [INFO] Skipping the initial load request for c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample
[2021-05-24 18:31:07.967] [INFO] Initialization finished
[2021-05-24 18:31:27.021] [INFO] Loading test files of c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample
[2021-05-24 18:31:27.023] [DEBUG] Using working directory: C:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample
[2021-05-24 18:31:27.239] [DEBUG] Using nodePath: C:\Program Files\nodejs\node.exe
[2021-05-24 18:31:27.610] [DEBUG] Using Mocha options: {"ui":"tdd","timeout":2000,"retries":0,"requires":[],"delay":false,"fullTrace":false,"exit":false,"asyncOnly":false,"parallel":false}
[2021-05-24 18:31:27.611] [DEBUG] Looking for test files ["out/test/**/*.test.js"] in c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample
[2021-05-24 18:31:27.616] [DEBUG] Found test files ["C:\\Users\\carloc\\Git\\hbenl\\vscode-extension-samples\\helloworld-test-sample\\out\\test\\suite\\extension.test.js"]
[2021-05-24 18:31:27.617] [DEBUG] Using environment variables from config: {"VSCODE_VERSION":"insiders","ELECTRON_RUN_AS_NODE":null,"VSCODE_LAUNCH_ARGS":"--disable-extensions"}
[2021-05-24 18:31:27.618] [DEBUG] Spawning c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample\node_modules\mocha-explorer-launcher-scripts\vscode-test with IPC options {"role":"client","port":9449,"host":"localhost"}
[2021-05-24 18:31:27.788] [ERROR] Worker (stderr): Failed to run tests: SyntaxError: Unexpected number in JSON at position 1
    at JSON.parse (<anonymous>)
    at c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample\node_modules\mocha-explorer-launcher-scripts\vscode-test\index.js:23:35
    at Generator.next (<anonymous>)
    at c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample\node_modules\mocha-explorer-launcher-scripts\vscode-test\index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample\node_modules\mocha-explorer-launcher-scripts\vscode-test\index.js:4:12)
    at c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample\node_modules\mocha-explorer-launcher-scripts\vscode-test\index.js:15:12
    at Object.<anonymous> (c:\Users\carloc\Git\hbenl\vscode-extension-samples\helloworld-test-sample\node_modules\mocha-explorer-launcher-scripts\vscode-test\index.js:42:3)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)

VSCODE_LAUNCH_ARGS takes a string, I am not sure why it is complaining about SyntaxError: Unexpected number in JSON

hbenl commented 3 years ago

VSCODE_LAUNCH_ARGS needs to be a JSON-encoded string array (I'll have to add documentation for this). Try with

"VSCODE_LAUNCH_ARGS": "[\"--disable-extensions\"]"