Skip to content

Instantly share code, notes, and snippets.

@wbern
Created May 19, 2020 09:10
Show Gist options
  • Save wbern/1a713087dcc2e6a5176de86fe907f923 to your computer and use it in GitHub Desktop.
Save wbern/1a713087dcc2e6a5176de86fe907f923 to your computer and use it in GitHub Desktop.
Let you run unit tests with breakpoints in vscode, using vue-cli-service
{
{
"type": "node",
"request": "launch",
"name": "vue-cli-service test:unit (by open package.json)",
"runtimeExecutable": "node",
"autoAttachChildProcesses": false,
"cwd": "${fileDirname}",
"args": [
"${fileDirname}/vue-cli-service-debug-bin.js",
"--inspect",
"${fileDirname}/node_modules/@vue/cli-service/bin/vue-cli-service.js",
"test:unit",
"--runInBand",
"--no-cache",
"--watch"
],
"internalConsoleOptions": "neverOpen",
"console": "integratedTerminal"
}
}
const fs = require("fs");
const { spawn } = require("child_process");
const path = require("path");
// we want to use this silly export statement without using shell
// because vscode debugger doesn't attach too well to the shell
let exportStatement = /export NODE_PATH="(.*)"/.exec(
fs.readFileSync(path.join(__dirname, "node_modules/.bin/vue-cli-service"))
)[1];
spawn(
"node",
process.argv.slice(2),
{
env: {
...process.env,
NODE_PATH: exportStatement + ":" + process.env.NODE_PATH
},
cwd: __dirname,
stdio: "inherit",
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment