Debugging unit tests
See original GitHub issue- [x ] I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
Debugging JS unit tests
Steps to Reproduce
Do you know if there is a way to debug JS unit tests for smart contracts? I use VS Code for development, and when I try to run a Mocha debugger it complains that artifacts
is not defined. I briefly looked at truffle code, it looks like it adds artifacts
, contract
and some other global js variables when it runs the unit tests. Is there a way for me to add those explicitly in the JS unit test file so I could debug that unit test file?
Expected Behavior
Be able to debug js unit tests
Actual Results
Not able to debug unit tests as artifacts
, contracts
and other JS objects injected by truffle are not present when running the debug session
Environment
- Operating System: Mac OSX
- Ethereum client: Ganache
- Truffle version (
truffle version
): 4.0.7 - node version (
node --version
): 7.7.3 - npm version (
npm --version
): 4.0.3 - IDE: VS Code
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Debug unit tests with Test Explorer - Visual Studio (Windows)
In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Note · In Test...
Read more >c# - Stepping through and debugging code in Unit tests
First locate the unit test that you want to debug · Double clicking on a unit test will open that unit test ·...
Read more >Debugging Unit Tests - Developer Documentation
Within Visual Studio (debugging run method)¶ · Right-click the test project, e.g. DataObjectsTest. · Select Properties. Under Debugging -> Command Arguments, type ...
Read more >Debugging tests - Angular
Click the DEBUG button to open a new browser tab and re-run the tests. Open the browser's Developer Tools. On Windows, press Ctrl-Shift-I...
Read more >Debugging Your Unit Test Suite in Python | Capital One
Unit tests involving mocked-out components can be very hard to specify correctly. Pytest has many features that can help, but among the most ......
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 Free
Top 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
Just for reference - the same solution above can be used to start the debugger from command line and debug in node inspector (in Chrome dev tools):
chrome://inspect
page and click the “Open dedicated DevTools for Node” link.cli.js
file with execution paused on the first line.Issue resolved, thanks to @lazaridiscom