Я не могу заставить отладку работать на VSCode для инфраструктуры тестирования E2E. Отображается только это сообщение - Ожидание отключения отладчика.
Однако я могу отладить и запустить простой код TS. Я начинаю задаваться вопросом, иду ли я даже в правильном направлении.
Ниже приведены tsconfig.json, package.json и launch.json для не работающих и рабочих проектов.
Каркас близок к тому, который предлагает транспортир. Установите транспортир, используя
npm install -g protractor
Вы увидите структуру в node_modules \ protractor \ exampleTypescript
tsconfig.json
{
"compilerOptions": {
"outDir": "tmp",
"rootDir": "./",
"sourceMap": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es2017",
"types": ["jasmine", "jasminewd2", "node"]
},
"exclude": [
"node_modules",
"asyncAwait",
"plugins.ts"
]
}
package.json
{
"name": "org_abc",
"version": "1.0.0",
"description": "org_abc_e2e automation tests",
"author": "org_abc",
"main": "./conf.ts",
"license": "org_abc",
"scripts": {
"webdriver-update": "npx webdriver-manager update",
"prestart": "npm run build",
"build": "tsc",
"tsc": "tsc",
"test": "npm run tsc && protractor tmp/conf.js"
},
"dependencies": {
"@types/jasmine": "^2.8.9",
"@types/jasminewd2": "^2.0.4",
"@types/node": "^10.12.0",
"adm-zip": "0.4.7",
"chance": "^1.0.16",
"chromedriver": "^2.41",
"colors": "1.1.2",
"geckodriver": "1.8.1",
"jasmine": "^2.99.0",
"jasmine-reporters": "2.2.1",
"jasmine-spec-reporter": "4.2.1",
"mocha": "^5.2.0",
"protractor": "^5.4.1",
"protractor-jasmine2-screenshot-reporter": "0.4.0",
"selenium-server": "^3.13.0",
"selenium-webdriver": "^4.0.0-alpha.1",
"ts-node": "^7.0.1",
"webdriver-manager": "^12.0.6",
"xml2js": "~0.4.19"
},
"devDependencies": {
"@types/jasmine": "^2.8.8",
"@types/jasminewd2": "^2.0.4",
"ts-node": "^7.0.1",
"typescript": "^2.9.2",
"yarn": "^1.10.1"
}
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "XPIA",
"program": "${workspaceFolder}\\conf.ts",
"preLaunchTask": "npm: build",
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"protocol": "auto",
"args": ["${workspaceRoot}\\conf.ts"],
"outFiles": [
"${workspaceFolder}/tmp/**/*.js"
]
}]
}
Отладочный вывод:
C:\Program Files\nodejs\node.exe --inspect-brk=31907 tmp\conf.js C:\Users\user_name\Documents\automation\conf.ts
Debugger listening on ws://127.0.0.1:31907/5ffdafc9-39d4-4f1a-afad-2593d4adacd7
Debugger attached.
Waiting for the debugger to disconnect...
===========================
Ниже приведен простой проект, и я могу его отладить:
В VS Code я создал файл TS с парой переменных и смог отладить.
tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"outDir": "./out",
"rootDir": "./src",
"sourceMap": true,
"moduleResolution": "node",
"target": "es5"
}
}
package.json
{
"name": "typescript-debugging",
"version": "1.0.0",
"description": "typescript-debugging-desc",
"main": "src/app.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node out/app.js",
"prestart": "npm run build",
"build": "tsc"
},
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^3.1.3"
}
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\src\\app.ts",
"preLaunchTask": "npm: build",
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outFiles": [
"${workspaceFolder}/out/**/*.js"
]
}]
}