How can I debug tests in Visual Studio Code?
See original GitHub issueI’m trying to debug tests in Visual Studio Code, but I always receive an error like the following:
import * as GalleriesHttpPort from "./GalleriesHttpPort";
^^^^^^
SyntaxError: Cannot use import statement outside a module
How can I properly debug in Visual Studio Code?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >Debug Tests in Visual Studio Code | Recipes | Docs - TestCafe
Before you debug in Visual Studio Code, ensure that your root test directory contains a package.json file that includes testcafe in the devDependencies...
Read more >How to Use VS Code to Debug Unit Test Cases | by Jennifer Fu
Click the following Run button on the left side panel. It presents an interface for Run and Debug. By specifying a proper configuration,...
Read more >Using Visual Studio Code to debug Jest based unit tests
We will click on the debug icon (left hand sidebar). Click on the add configuration option in the dropdown list. Choose nodejs (jest...
Read more >VS Code: Debugging with Jest - gists · GitHub
Start debugging · Open the unit test file you want to debug. · Set breakpoints or the debugger statement where you want to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve also been trying tirelessly to get this working. Here are my finds so far:
Running
serverless-bundle test --some-arg=foo
does in fact pass the arg to jest. I tested this both by logging theargv
in the serverless-bundle scripts that get passed to jest, as well as by trying to pass an unsupported arg to jest, upon which it threw an error:I’m not sure however, how you would pass specific arguments to webpack or else-wise.
I was able to get VSCode Debugging w/ Breakpoints working in JS & Typescript files, though. Here’s my launch.json:
I also have a custom directive in
serverless.yml
, though I’m not 100% certain it’s needed anymore:For now, I just have it running this one service, but I intend to make it more universal. I can successfully hit
http://localhost:4000/someserverlessfunc
and it hits breakpoints in all file types. It’s fickle sometimes and requires me to run it twice, and the dots are always grey because VSCode can’t make the connection between src/dist files in this case for some reason, but it works.In
serverless-bundle test
, I’m unable to get VSCode to hit breakpoints in plain JS test files, JS src files, webpack-generated files or anything; not even with adebugger;
statement. I’ve looked at thejest-starter
above, but didn’t find it to be terribly helpful yet, and I’ve experimented with a LOT oflaunch.json
params, based on my working debug config and possible changes I’ve found on the web. So far no luck.My experience with webpack, etc isn’t terribly deep, so I’m not 100% certain where to go from here. Does anyone at least have an idea of where to go from here, or at least some knowledge of how the
VSCode -> Jest/Babel
relationship works for debug that might help me tinker more?Thanks!
@zlanich i have tried your solution in windows, but didn’t work for me, is your solutions work for windows or other oprating system.
Anyone got any solution regarding it.