Node.js 调试器有一个默认值 --inspect-brk=PORT 而没有在脚本中指定它
Node.js debugger has a default value of --inspect-brk=PORT without specifying this in the script
当我 运行 我的 mocha 在调试模式下测试时,Node.js 调试器有一个默认值用作 --inspect-brk=
值。
没有在脚本中指定它,我的测试脚本看起来像那样
--timeout=15000 --appName=ejbrowser --role=adminUserOne --env=tst --reporter=spec tests/api/ejbrowser/devices/all.spec.js --failureFatal=1
但是当我在调试模式下 运行 时,正在执行的脚本是:
C:\Program Files\nodejs\node.exe" C:\repos\yyc-api-ui-automation\node_modules\mocha\bin\mocha --inspect-brk=57629 --appName=ejbrowser --role=adminUserOne --env=tst --timeout=60000 --slow=2000 --reporter=mochawesome tests/ui/-common/-health-checks-lvl1/all.spec.js --browserClient=chrome --failureFatal=1 --timeout 0 --ui bdd --reporter "C:\Program Files\JetBrains\IntelliJ IDEA 2021.3\plugins\NodeJS\js\mocha-intellij\lib\mochaIntellijReporter.js"
这个值--inspect-brk=57629
从哪里来的?
我工作的项目不接受 commandLineArgs 中的这个参数,我不得不修改它以接受 { partial: true} 这并不完美。所以我试图了解填充此值的内容。
我用的是IntelliJ idea 2021.3.2 Ultimate
package.json :
{
"name": "cloudexa-yyc-automation",
"version": "1.0.0",
"description": "Java Script | Selenium Functional Automation Tests with Mocha / API Automation Tests with Supertest",
"author": "Valeriu Jecov",
"license": "ISC",
"main": "index.js",
"homepage": "",
"bugs": {
"url": "https://jira.esq.com/secure/Dashboard.jspa",
"email": "valeriu.jecov@cloudexa.com"
},
"repository": {
"type": "git",
"url": "https://git.esq.com/esq/qa/automation/automation"
},
"scripts": {
"test:all": "mocha --timeout 5000 --reporter=mochawesome tests/*/*.js --failureFatal=1",
"api:all": "mocha --timeout 10000 --reporter=mochawesome tests/api/*.js --failureFatal=1",
"api:amq": "mocha --timeout=10000 --reporter=spec tests/api/__playgrounds/amqpTest.js --failureFatal=1",
"api:gorest": "mocha --timeout 5000 --reporter=mochawesome tests/api/__playgrounds/optimized-users-posts.js --failureFatal=1",
"api:stardust:all": "mocha --timeout=15000 --reporter=spec tests/api/stardust/StardustPOC/all.spec.js --failureFatal=1",
"api:ejbrowser:devices": "mocha --timeout=15000 --reporter=spec tests/api/ejbrowser/devices/all.spec.js --failureFatal=1",
"api:checkbrowser:check-files": "mocha --timeout=15000 --reporter=spec tests/api/checkbrowser/check-files/all.spec.js --failureFatal=1",
"ui:all": "mocha --timeout=30000 --slow=2000 tests/ui/*/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlOne:all": "mocha --timeout=60000 --slow=2000 tests/ui/-common/-health-checks-lvl1/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlOne:loginLogOut": "mocha --timeout=60000 --slow=2000 tests/ui/-common/-health-checks-lvl1/logInLogOut.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlOne:switcher": "mocha --timeout=60000 --slow=2000 tests/ui/-common/-health-checks-lvl1/switcher.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:ejbrowser_mercy": "mocha --timeout=60000 --slow=2000 tests/ui/ejbrowser/mercyAndAdele/mercy_all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:ejbrowser_adele": "mocha --timeout=60000 --slow=2000 tests/ui/ejbrowser/mercyAndAdele/adele_all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:ejbrowser": "mocha --timeout=60000 --slow=2000 --appName=ejbrowser tests/ui/ejbrowser/-health-checks/two.spec.js --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:incidentmanager": "mocha --timeout=60000 --slow=2000 --appName=incidentmanager ./tests/ui/incidentmanager/-health-checks/two.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:monitoring": "mocha --timeout=60000 --slow=2000 --appName=monitoring tests/ui/monitoring/-health-checks/two.spec.js --failureFatal=1 --reporter=mochawesome",
"ui:incidentmanager:crud:incidents": "mocha --timeout=80000 --slow=2000 --appName=incidentmanager ./tests/ui/incidentmanager/create-edit-delete-incident/crud-incident.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:monitoring:all": "mocha --timeout=80000 --slow=2000 --appName=monitoring tests/ui/monitoring/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:dataanalyzer:all": "mocha --timeout=60000 --slow=2000 --appName=dataanalyzer ./tests/ui/dataanalyzer/*/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:dispatcher:all": "mocha --timeout=60000 --slow=2000 --appName=dispatcher ./tests/ui/dispatcher/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:documentation:all": "mocha --timeout=60000 --slow=2000 --appName=documentation ./tests/ui/documentation/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:fieldservice:all": "mocha --timeout=60000 --slow=2000 --appName=fieldservice ./tests/ui/fieldservice/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:obadminclient:all": "mocha --timeout=60000 --slow=2000 --appName=obadminclient ./tests/ui/obadminclient/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:rbac:all": "mocha --timeout=60000 --slow=2000 --appName=rbac ./tests/ui/rbac/*/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:reporter:all": "mocha --timeout=60000 --slow=2000 --appName=reporter ./tests/ui/reporter/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:workspace:all": "mocha --timeout=60000 --slow=2000 --appName=workspace ./tests/ui/workspace/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome"
},
"keywords": [],
"devDependencies": {
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.8",
"@babel/node": "^7.13.0",
"@babel/plugin-transform-runtime": "7.12.13",
"@babel/preset-env": "^7.13.9",
"@babel/register": "^7.13.8",
"base-64": "^1.0.0",
"browserstack-local": "^1.4.8",
"chai": "^4.3.3",
"command-line-args": "^4.0.6",
"deferred": "^0.7.11",
"dotenv": "^8.2.0",
"faker": "^5.4.0",
"fs-extra": "^9.1.0",
"iedriver": "^3.150.1",
"jira-client": "^6.21.1",
"jshint": "^2.12.0",
"jsonfile": "^6.1.0",
"mocha": "^9.2.1",
"mochawesome": "^7.1.2",
"moment": "^2.29.1",
"npm": "^8.5.4",
"rhea": "^1.0.24",
"selenium-webdriver": "^4.1.1",
"supertest": "^6.1.3"
},
"jshintConfig": {
"esversion": 6,
"laxcomma": true,
"expr": true
}
}[enter image description here][1]
如何禁用调试模式(节点的检查功能)
使用“-”按钮从 intellij 中删除调试配置。或者只是 运行 您在“运行 模式”下应用,而不是使用 IDE.
中的“运行 调试”模式
如何选择调试端口号
57629只是intellij配置的debug默认端口号
要更改它,请打开 intellij 并转到 运行 |编辑配置 |添加新配置 |附加到节点。js/Chrome
然后,更改端口字段值。
我找到了导致它的原因。不幸的是,我的临时目录包含空格,将它传递给 NODE_OPTIONS 时无法转义空格。所以 IDE 使用明确的 --inspect 开关。作为解决方法,我在帮助 > 编辑自定义 VM 选项 (Djava.io.tmpdir=C:\tmp) 中指定了一个不同的 TEMP 目录,它解决了这个问题。
当我 运行 我的 mocha 在调试模式下测试时,Node.js 调试器有一个默认值用作 --inspect-brk=
值。
没有在脚本中指定它,我的测试脚本看起来像那样
--timeout=15000 --appName=ejbrowser --role=adminUserOne --env=tst --reporter=spec tests/api/ejbrowser/devices/all.spec.js --failureFatal=1
但是当我在调试模式下 运行 时,正在执行的脚本是:
C:\Program Files\nodejs\node.exe" C:\repos\yyc-api-ui-automation\node_modules\mocha\bin\mocha --inspect-brk=57629 --appName=ejbrowser --role=adminUserOne --env=tst --timeout=60000 --slow=2000 --reporter=mochawesome tests/ui/-common/-health-checks-lvl1/all.spec.js --browserClient=chrome --failureFatal=1 --timeout 0 --ui bdd --reporter "C:\Program Files\JetBrains\IntelliJ IDEA 2021.3\plugins\NodeJS\js\mocha-intellij\lib\mochaIntellijReporter.js"
这个值--inspect-brk=57629
从哪里来的?
我工作的项目不接受 commandLineArgs 中的这个参数,我不得不修改它以接受 { partial: true} 这并不完美。所以我试图了解填充此值的内容。
我用的是IntelliJ idea 2021.3.2 Ultimate
package.json :
{
"name": "cloudexa-yyc-automation",
"version": "1.0.0",
"description": "Java Script | Selenium Functional Automation Tests with Mocha / API Automation Tests with Supertest",
"author": "Valeriu Jecov",
"license": "ISC",
"main": "index.js",
"homepage": "",
"bugs": {
"url": "https://jira.esq.com/secure/Dashboard.jspa",
"email": "valeriu.jecov@cloudexa.com"
},
"repository": {
"type": "git",
"url": "https://git.esq.com/esq/qa/automation/automation"
},
"scripts": {
"test:all": "mocha --timeout 5000 --reporter=mochawesome tests/*/*.js --failureFatal=1",
"api:all": "mocha --timeout 10000 --reporter=mochawesome tests/api/*.js --failureFatal=1",
"api:amq": "mocha --timeout=10000 --reporter=spec tests/api/__playgrounds/amqpTest.js --failureFatal=1",
"api:gorest": "mocha --timeout 5000 --reporter=mochawesome tests/api/__playgrounds/optimized-users-posts.js --failureFatal=1",
"api:stardust:all": "mocha --timeout=15000 --reporter=spec tests/api/stardust/StardustPOC/all.spec.js --failureFatal=1",
"api:ejbrowser:devices": "mocha --timeout=15000 --reporter=spec tests/api/ejbrowser/devices/all.spec.js --failureFatal=1",
"api:checkbrowser:check-files": "mocha --timeout=15000 --reporter=spec tests/api/checkbrowser/check-files/all.spec.js --failureFatal=1",
"ui:all": "mocha --timeout=30000 --slow=2000 tests/ui/*/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlOne:all": "mocha --timeout=60000 --slow=2000 tests/ui/-common/-health-checks-lvl1/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlOne:loginLogOut": "mocha --timeout=60000 --slow=2000 tests/ui/-common/-health-checks-lvl1/logInLogOut.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlOne:switcher": "mocha --timeout=60000 --slow=2000 tests/ui/-common/-health-checks-lvl1/switcher.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:ejbrowser_mercy": "mocha --timeout=60000 --slow=2000 tests/ui/ejbrowser/mercyAndAdele/mercy_all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:ejbrowser_adele": "mocha --timeout=60000 --slow=2000 tests/ui/ejbrowser/mercyAndAdele/adele_all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:ejbrowser": "mocha --timeout=60000 --slow=2000 --appName=ejbrowser tests/ui/ejbrowser/-health-checks/two.spec.js --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:incidentmanager": "mocha --timeout=60000 --slow=2000 --appName=incidentmanager ./tests/ui/incidentmanager/-health-checks/two.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:healthChecks:lvlTwo:monitoring": "mocha --timeout=60000 --slow=2000 --appName=monitoring tests/ui/monitoring/-health-checks/two.spec.js --failureFatal=1 --reporter=mochawesome",
"ui:incidentmanager:crud:incidents": "mocha --timeout=80000 --slow=2000 --appName=incidentmanager ./tests/ui/incidentmanager/create-edit-delete-incident/crud-incident.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:monitoring:all": "mocha --timeout=80000 --slow=2000 --appName=monitoring tests/ui/monitoring/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:dataanalyzer:all": "mocha --timeout=60000 --slow=2000 --appName=dataanalyzer ./tests/ui/dataanalyzer/*/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:dispatcher:all": "mocha --timeout=60000 --slow=2000 --appName=dispatcher ./tests/ui/dispatcher/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:documentation:all": "mocha --timeout=60000 --slow=2000 --appName=documentation ./tests/ui/documentation/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:fieldservice:all": "mocha --timeout=60000 --slow=2000 --appName=fieldservice ./tests/ui/fieldservice/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:obadminclient:all": "mocha --timeout=60000 --slow=2000 --appName=obadminclient ./tests/ui/obadminclient/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:rbac:all": "mocha --timeout=60000 --slow=2000 --appName=rbac ./tests/ui/rbac/*/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:reporter:all": "mocha --timeout=60000 --slow=2000 --appName=reporter ./tests/ui/reporter/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome",
"ui:workspace:all": "mocha --timeout=60000 --slow=2000 --appName=workspace ./tests/ui/workspace/-health-checks/all.spec.js --browserClient=chrome --failureFatal=1 --reporter=mochawesome"
},
"keywords": [],
"devDependencies": {
"@babel/cli": "^7.13.0",
"@babel/core": "^7.13.8",
"@babel/node": "^7.13.0",
"@babel/plugin-transform-runtime": "7.12.13",
"@babel/preset-env": "^7.13.9",
"@babel/register": "^7.13.8",
"base-64": "^1.0.0",
"browserstack-local": "^1.4.8",
"chai": "^4.3.3",
"command-line-args": "^4.0.6",
"deferred": "^0.7.11",
"dotenv": "^8.2.0",
"faker": "^5.4.0",
"fs-extra": "^9.1.0",
"iedriver": "^3.150.1",
"jira-client": "^6.21.1",
"jshint": "^2.12.0",
"jsonfile": "^6.1.0",
"mocha": "^9.2.1",
"mochawesome": "^7.1.2",
"moment": "^2.29.1",
"npm": "^8.5.4",
"rhea": "^1.0.24",
"selenium-webdriver": "^4.1.1",
"supertest": "^6.1.3"
},
"jshintConfig": {
"esversion": 6,
"laxcomma": true,
"expr": true
}
}[enter image description here][1]
如何禁用调试模式(节点的检查功能)
使用“-”按钮从 intellij 中删除调试配置。或者只是 运行 您在“运行 模式”下应用,而不是使用 IDE.
中的“运行 调试”模式如何选择调试端口号
57629只是intellij配置的debug默认端口号
要更改它,请打开 intellij 并转到 运行 |编辑配置 |添加新配置 |附加到节点。js/Chrome
然后,更改端口字段值。
我找到了导致它的原因。不幸的是,我的临时目录包含空格,将它传递给 NODE_OPTIONS 时无法转义空格。所以 IDE 使用明确的 --inspect 开关。作为解决方法,我在帮助 > 编辑自定义 VM 选项 (Djava.io.tmpdir=C:\tmp) 中指定了一个不同的 TEMP 目录,它解决了这个问题。