Home > Software engineering >  Node.js debugger has a default value of --inspect-brk=PORT without specifying this in the script
Node.js debugger has a default value of --inspect-brk=PORT without specifying this in the script

Time:03-17

When I run my mocha tests in debug mode, Node.js debugger has a default value used as the --inspect-brk= value. Without specifying it in the script, my test script looks like that

--timeout=15000 --appName=ejbrowser --role=adminUserOne --env=tst --reporter=spec tests/api/ejbrowser/devices/all.spec.js --failureFatal=1

But when I run it with debug mode the script that is being executed is:

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"

Where does this value --inspect-brk=57629 come from?

The project that I work on doesn't accept this parameter in commandLineArgs and I had to modify it to accept { partial: true} which is not perfect. So I am trying to understand what is populating this value.

I use 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": "[email protected]"
  },
  "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]

CodePudding user response:

How to disable the debug mode (node's inspect features)

Remove your debug configurations from intellij using the "-" button. Or just run you application in "run mode", not using the "run debug" mode from the IDE.

run/debug configurations

How to choose the debug port number

57629 is just the default port number for debug configured by intellij.

To change it, open intellij and go to Run | Edit Configurations | Add New Configuration | Attach to Node.js/Chrome

Then, change the Port field value.

Reference

CodePudding user response:

I found what caused it. My temporary directory contains spaces and there's no way to escape spaces when passing it to NODE_OPTIONS unfortunately. So the IDE uses the explicit --inspect switch. As a work around I specified a different TEMP dir in Help > Edit Custom VM Options (Djava.io.tmpdir=C:\tmp) and it solved the issue.

  • Related