-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Built-in debug mode #1505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I came here to make the very same request. If the parent |
We'd have to change the concurrency to Besides that, perhaps a |
Yes, this sounds ideal. Can you reference the location in the code where this change would need to be made and one of us open source contributors can get to work on it? |
Sure thing. Concurrency is determined here: https://github.com/avajs/ava/blob/1df502df8cba18f92afcbaed730d8c724687ca45/api.js#L164:L174 We massage the https://github.com/avajs/ava/blob/1df502df8cba18f92afcbaed730d8c724687ca45/api.js#L177:L221 Looking at that I think these are |
Another option here I'd love to see considered: a standard-feeling One of my favorite aspects about AVA is the apparent lack of "magic" – test files look normal, and testing infrastructure must be imported rather than magically appearing in globals. Even when AVA performs some "magic" for Babel compilation, users interact with it like normal javascript, so there's nothing new to learn/configure. I'd love to see this philosophy carry over to debugging. It would seem much more intuitive for me to be able to debug AVA tests using the same configuration as my other work. Rather than configuring my tooling to use an E.g. It's pretty difficult to get debugging of AVA tests working in VSCode with TypeScript right now. I'm working from this recipe. And it doesn't seem possible to get "one-click" debugging without changes to either AVA or VSCode. (I'm still looking for workarounds in typescript-starter@next.) RecommendationWhen executing a test outside of the CLI, AVA could look for either:
If found, AVA can setup the infrastructure currently in Of course, if a "debug mode" isn't detected, AVA can still log the Related: #1495 |
To provide an example of where diverging from the the |
We should support the modern |
Have folks seen https://github.com/GoogleChromeLabs/ndb? Would be great to make AVA work with that out of the box. |
This feature is really a necessity. When launched with --inspect it should run tests one at a time and break on the first debugger statement. |
@krisnye I agree! Would you like to help us make it a reality? |
Maybe, you'll take a pull request with it? |
That's what the issue is for. |
whats the status of this? |
Still open, clearly. |
@FinnFrotscher would you like to give this a go? |
I have switched to Mocha to get around this problem, but the solution is not satisfactory since it comes with another set of drawbacks. |
@FinnFrotscher the Node.js flags passed to the worker processes are controlled here: Line 269 in ed7807e
AVA's CLI flags are here: Line 56 in ed7807e
There's more stuff in |
The V8 inspector is available programatically, which could be another interesting approach: https://nodejs.org/api/inspector.html |
@novemberborn Actually that seems to work really nice. No need to setup separate test runner scripts to package.json to run in serial mode etc. and when ever I need to stop execution to wait for debugger I can call in test this:
|
It would really be nice if we could just pass a convenient I've read the guide https://github.com/avajs/ava/blob/master/docs/recipes/debugging-with-chrome-devtools.md here and found it requires a bit of muscle power to point to an actual test module and think this would be just the thing to take that work away. |
@0maxxam0 has funded $10.00 to this issue.
|
@IssueHunt has funded $60.00 to this issue.
|
Food for thought, since we've been dancing around it but haven't stated it explicitly: Generally, when we are actively debugging a test, we are actively debugging a single test, not all of our tests. In most cases, we are using the test as an entry point to debug specific code. Sometimes we're debugging the test itself. We can already tell ava to run a specific file, and even a specific test in that file with Unfortunately, for now, because the official documentation says to use
|
Yes, this is a nuisance. @mschnee as a workaround you can add a run script such as:
|
This looks like an honest oversight in In lieu of debug mode being added to AVA itself, have any of you tried using ndb? You can launch it ( |
FYI - that cache directory 'fix' will not work in native monorepositories. The last thing you want to do is Ava/ I would much rather see support in ava for explicitly running (and debugging/inspecting) a single test directly (a specific test in a specific file, or just a specific file). This would additionally enable a host of other things, like the possibility of creating a TestExplorer plugin for ava, better UI integration, etc. |
I'm pretty sure we hook into the module loading and retrieve the file contents from the cache directory, without impacting the require paths. If this is causing problems in monorepos could you open a separate issue to discuss? |
@novemberborn the programmatic use of |
@geoffp oh that's great! I think for a start let's make sure we have that covered in a recipe. |
@novemberborn okay. Let me know if you want a hand writing that up. |
@geoffp yes I haven't used this myself. Perhaps you could kick this off? Always better coming from somebody who's used the thing. |
@novemberborn Sure thing. I'll try to carve out the time in the coming week! |
Here are some thoughts I have on this implementing AVA test debugging for the VSCode AVA Test Explorer plugin I wrote:
If anyone is curious, the work around to make test debugging work in my plugin is: const api = new Api({ /* options */})
if (port) { // port is previously selected with the get-port module.
const original = api._computeForkExecArgv.bind(api)
api._computeForkExecArgv = async function(): Promise<string[]> { // typescript
const base = await original()
const filtered = base.filter((a): boolean => !a.startsWith('--inspect'))
return filtered.concat(`--inspect-brk=${port}`) // VSCode always expects the debug target to break.
}
} The reporter used with this triggers a debug session for the selected port when it's startRun method is called. |
Hi @Gwenio, I saw your post on Spectrum and have been meaning to look that up. Very nice! We're currently not interested in supporting programmatic use of the |
If I understand correctly, the current best workaround is to use node inspector programatically. I couldn't get the inspect-process thing to work, some sort of weirdness with So in the short term we're going to update the debugging-with-chrome-devtools recipe right? I haven't really played around with it much, but I think it's as easy as this:
Probably not worth including in the docs here, but as an aside waiting for the debugger to connect seems somewhat broken in node 12.1.0. Rather than |
That'd be great.
That's a really old version of Node.js 12 though. |
Uh oh!
There was an error while loading. Please reload this page.
@Qix- in #1108 (comment):
The text was updated successfully, but these errors were encountered: