0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: improve vscode debugging (#969)

* chore: improve vscode debugging

* chore: add functional test settings to vscode
This commit is contained in:
Juan Picado @jotadeveloper 2018-09-03 21:11:52 +02:00 committed by GitHub
parent 5ca0ca5228
commit a5f5004a27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 27 deletions

71
.vscode/launch.json vendored
View file

@ -6,55 +6,72 @@
"configurations": [ "configurations": [
{ {
"type": "node", "type": "node",
"request": "attach", "request": "launch",
"name": "Attach to Process", "name": "CLI Babel Registry",
"processId": "${command:PickProcess}", "stopOnEntry": false,
"port": 5858 "program": "${workspaceFolder}/debug/bootstrap.js",
"env": {
"BABEL_ENV": "registry"
},
"preLaunchTask": "npm: build:webui",
"console": "integratedTerminal"
}, },
{ {
"name": "Tests", "name": "Unit Tests",
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js", "program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
"stopOnEntry": false, "stopOnEntry": false,
"args": ["--runInBand"], "args": [
"--debug=true" ],
"cwd": "${workspaceRoot}", "cwd": "${workspaceRoot}",
"preLaunchTask": null, "preLaunchTask": "pre-test",
"runtimeExecutable": null, "runtimeExecutable": null,
"runtimeArgs": [ "runtimeArgs": [
"--nolazy" "--nolazy"
], ],
"env": { "env": {
"NODE_ENV": "test" "NODE_ENV": "test",
"TZ": "UTC"
}, },
"externalConsole": false, "console": "integratedTerminal"
"sourceMaps": false,
"outDir": null
}, },
{ {
"name": "Functional Tests",
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Mocha Tests", "program": "${workspaceRoot}/node_modules/.bin/jest",
"stopOnEntry": false, "stopOnEntry": false,
"runtimeExecutable": null,
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [ "args": [
"--no-timeouts", "--config",
"${workspaceRoot}/test/unit" "./test/jest.config.functional.js",
] "--testPathPattern",
"./test/functional/index*",
"--debug=false",
"--verbose",
"--useStderr",
"--detectOpenHandles"],
"cwd": "${workspaceRoot}",
"env": {
"BABEL_ENV": "testOldEnv",
"VERDACCIO_DEBUG": "true",
"VERDACCIO_DEBUG_INJECT": "true",
"NODE_DEBUG": "TO_DEBUG_REQUEST_REMOVE_THIS_request"
},
"preLaunchTask": "pre-test",
"console": "integratedTerminal",
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
}, },
{ {
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Verdaccio", "name": "Verdaccio Compiled",
"program": "${workspaceRoot}/bin/verdaccio" "preLaunchTask": "npm: code:build",
}, "program": "${workspaceRoot}/bin/verdaccio",
{ "console": "integratedTerminal"
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
} }
] ]
} }

24
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,24 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build:webui",
"problemMatcher": []
},
{
"type": "npm",
"script": "code:build",
"problemMatcher": []
},
{
"label": "pre-test",
"dependsOn": [
"npm: code:build",
"npm: test:clean"
]
}
]
}

View file

@ -157,6 +157,7 @@
"flow": "flow check", "flow": "flow check",
"pretest": "npm run code:build", "pretest": "npm run code:build",
"test": "npm run test:unit", "test": "npm run test:unit",
"test:clean": "npx jest --clearCache",
"test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest.config.js --maxWorkers 2", "test:unit": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest.config.js --maxWorkers 2",
"test:functional": "cross-env NODE_ENV=testOldEnv jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index*", "test:functional": "cross-env NODE_ENV=testOldEnv jest --config ./test/jest.config.functional.js --testPathPattern ./test/functional/index*",
"test:e2e": "cross-env BABEL_ENV=testOldEnv jest --config ./test/jest.config.e2e.js", "test:e2e": "cross-env BABEL_ENV=testOldEnv jest --config ./test/jest.config.e2e.js",

View file

@ -77,6 +77,10 @@ class FunctionalEnvironment extends NodeEnvironment {
async teardown() { async teardown() {
await super.teardown(); await super.teardown();
console.log(chalk.yellow('Teardown Test Environment.')); console.log(chalk.yellow('Teardown Test Environment.'));
if (!this.global.__SERVERS_PROCESS__) {
throw new Error("There are no servers to stop");
}
// shutdown verdaccio // shutdown verdaccio
for (let server of this.global.__SERVERS_PROCESS__) { for (let server of this.global.__SERVERS_PROCESS__) {
server[0].stop(); server[0].stop();