-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
AssertionError when debugging in VS Code #2946
Comments
That is peculiar. Are you breaking on (un)caught exceptions by any chance? I think this would occur if the test file is run directly, though going by the configuration I wouldn't expect that to happen. Does debugging work through use VS Code's "debug terminal" feature? There's a known issue where |
Both "caught exceptions" and "uncaught exceptions" are unchecked. I removed all my other breakpoints as well but it still happens regardless of having breakpoints. Using the Javascript Debug Terminal and running |
I know nothing about the internals of AVA but I did find this assert, and the |
You can provide a specific test file as an argument.
It is the problem, but under normal execution it is supposed to be assigned. The question is why is that not happening. |
Alright thank you for your time. If you still need any more info regarding solving this issue, please let me know. :) |
Running into this, very weird. Running
|
Interesting hunch! Though the tests run in fresh worker threads so I wouldn't expect any caching to be in play. Does it work if you configure AVA with |
For me setting |
I am also encountering this error. Unfortunately, the only option that I have at this point is to stop using ava. I did try completely clearing the node module cache, after rebooting, and it didn't change a thing. I should add that I've been using ava 3 for quite some time now without problems, but I'm opposed to continuing to use a library once a new version is released. FYI, I've upgraded ALL instances of ava to version 4 so it's not a problem with mixing versions. |
I just ran into it again a few minutes ago. It's a caching issue of some kind. |
I can't reproduce this.
I tried with a I did not try with a TypeScript file to then make use of If somebody could share a project in which this is reproducible I can take another look. |
Unfortunate that you weren't able to reproduce it. I just made a new project with:
I did notice VS Code states it's using Node.js version 14.16.0 in the About window, The project: ava-error-project.zip It's nothing more than...
Plus the launch.json, AVA config in package.json and two test files. The problem unfortunately still occurs in both Typescript and regular CJS files. It also occurs without TS-Node (after removing it). They all give:
If it cannot be fixed, it seems I'll have to stay on version 3.x indefinitely. |
It's not surprising that you couldn't reproduce it because it's a nondeterministic bug. Closing this issue is inappropriate but you're free to do it, though that would mean this software is no longer being actively maintained. |
Thanks @Basssiiie — I'm on a different machine now, so Node.js 16.13.0 which I happen to have installed. It's all working fine. I wonder if this is a Windows issue? I'm on Mac. What are the others using? Under normal circumstances this really shouldn't be happening. AVA sets up I don't think that's due to AVA itself. It could either be VS Code or This presumed non-standard behavior also makes this really hard to debug and understand. |
@ctjlewis please understand that I maintain AVA as a hobby — I have plenty of work obligations and non-computer stuff to get on with. I'd appreciate it if you'd bring a constructive and positive attitude to your comments here, rather than dismissing my efforts. Sometimes it can be better not to press that "Comment" button. |
So I could be completely wrong, and there could be some huge voodoo JS-magic that's happening, but maybe it's CJS thing rather than ESM? // ./lib/worker/main.cjs
const {flags, refs} = require('./state.cjs');
assert(refs.runnerChain);
// ./lib/worker/state.cjs
exports.refs = {runnerChain: null}; Wouldn't this more or less be equivalent to |
@TheBrenny it's assigned here: Line 68 in c5d2b53
This is the code that is managed by AVA. By the time the test file is loaded, which ends up loading |
import test from 'ava';
test('sync test', (t) => {
t.pass();
});
test('async test', async (t) => {
const bar = Promise.resolve('bar');
t.is(await bar, 'bar');
});
It's environment, for sure:
|
@clshortfuse are you saying this is a Node.js 14 issue? Why does it work the second time? And what OS are you using? |
@novemberborn Sorry for not getting back to you sooner. I have a project that is expected to support v12, v14, and v16. By default I test on v16. I use Therefore, |
In case of compiled binaries, an
No, AVA assumes it's installed locally.
There is no believing here. It just runs with what's there. But the only thing I'd expect to be different, based on the Node.js version under which you install dependencies, are compiled binaries. |
@novemberborn Right, but But if you look at the previous comment,
So, |
Just for the record. This thread has been very useful for me. Thanks! Using the VLC Downgrading to AVA v3 also helps to overcome the stubborness of VSC. I am also developing on Windows 10 and with the combination of recent Node.js v14 and default npm v6. But I can reproduce the issue with Node.js v16 and npm v8 as well. |
I had the same problem reported by @Basssiiie when debugging my javascript project on windows. I solved by adjusting the launch as follows: {
"type": "node",
"request": "launch",
"name": "Debug AVA test file",
"program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs",
"args": [
"${file}"
],
"outputCapture": "std",
"console": "integratedTerminal",
"skipFiles": [
"<node_internals>/**/*.js"
]
} |
@AlencarGabriel which change was critical? Pointing at the |
Hi @novemberborn , pointing to the cli.mjs entry point. Running ava.cmd directly does not result in errors, only when run via launch in VsCode. |
@AlencarGabriel @novemberborn Your launch.json works for me as well! I can debug in VS Code again! 🥳 Another difference is that it's using See the diff of the new file here: |
@AlencarGabriel lovely! Would you want to open a PR to change the recommended configuration? |
Done. Glad I could help! |
I ran into this issue even using the configuration recommend in this thread, and wanted to share the problem and solution for other Googlers. TL;DRDifferent copies of Long answerMy project has nested package.json files (and nested node_modules), and each package specified
So there were multiple copies of |
…y value - suspect this is due to some sort of ava instance mismatch. see avajs/ava#2946 (comment)
…y value - suspect this is due to some sort of ava instance mismatch. see avajs/ava#2946 (comment)
Hey I've been using the VS Code debugger launch configuration from here for quite a while now, but since updating to V4 I cannot get it to work anymore. Whenever I run it, I run into this error on any of the test files:
The example test file used (the error occurs on any test file though):
The VS Code
launch.json
(exact copy from the linked docs):AVA configuration in
package.json
:Running
npx ava --version
reports 0.1.0? I have 4.0.1 installed according to thepackage.json
and thenode_modules/ava
folder and bothnpm install
andnpm update
do not change that.AVA debugging still works in another project running 3.15
This sounds like a bug right?
Thank you for your time!
The text was updated successfully, but these errors were encountered: