-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
Description
It would be beneficial to have Node.js debugging capabilities for tests.
Note:
Currently, when starting node-qunit CLI in debug mode using --debug-brk child processes created by testrunner are created with the same debugging port, which causes an error.
Requirements:
node-qunitshould have a configurable parameter that will trigger child processes to run in debug mode on port provided by this parameter.- If
node-qunititself is running in debug mode and no port is provided by parameter,node-qunitshould be able to find free port and use it for debugging of child process. - Since
node-qunitspawns new process for each test file, debugging port should be configurable for each test file. - Infinite loop validation should be disabled for child processes running in debug mode
Usage:
- Using
--debugparameter and list of ports in the same order as test files
$ node node_modules/qunit/bin/cli.js -c code.js -t test1.js test2.js --debug 54890 40893
- Starting
node-qunitin debug mode using--debug-brk
$ node --debug-brk=56566 node_modules/qunit/bin/cli.js -c code.js -t test1.js test2.js
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
kof commentedon Nov 4, 2014
Could we fully automate ports selection so that there is no need for defining ports?
micellius commentedon Nov 4, 2014
Yes, it's exactly the second case in the usage section, where no ports configuration is provided and they are chosen automatically. Once process is running in debug mode NodeJS prints debug port, so auto generated port will be sufficient to connect to the process using debugger. Port configuration option is mostly enhancement that will allow to have some fixed debugging configuration in IDE (I'm using "Node.js remote debug" option in WebStorm) that should not be updated each time. I'm currently working on PR, but I'm pretty sure that your implementation will be definitely better.
Regarding implementation I think it should be something like the code below (in testrunner.js before forking the process)
Inspired by this post on StackOverflow.
To find free port freeport or find-free-port may be used.
P.S.
Thanks a lot for your responsiveness and cooperation! I'm really appreciate this.
Add test debugging support
micellius commentedon Nov 4, 2014
After looking on code more deep I realised that
cli.jsspawns only one child process (spawning multiple child processes is only available via API), thus there is no need in list of ports - only one debugging port is needed. Specifying port is also may be optional since it may be auto generated.@kof I've submitted PR few minutes ago, please take a look. I'm sure you know how to do it better, but idea remains the same. At least for me it solved the problem with test debugging.
[-][Feature Request] Add capability to debug tests[/-][+]Add support for using 'node --inspect' to debug tests[/+]rromanchenko commentedon Jan 3, 2018
Hi, guys. Just curious, if you are going to complete this enhancement and provide an ability to debug execution of tests by node-qunit?
Thanks.
Krinkle commentedon Sep 12, 2020
I believe you can use Node.js CLI options such as
--inspectvia the NODE_OPTIONS environment variable. For example:That will not cover sub processes, but at least it solves the issue of being able to use the
qunitcommand without needin the full path to the js file with thenodecommand.Also consider using the official QUnit CLI, which might suite your needs: https://qunitjs.com/cli/