Debugging javascript running in Chrome using VSCode
Installation steps:
- Install mocha NPM module
npm install npm install mocha chai --save-dev sudo npm install -g mocha
<html> <head> <link rel="stylesheet" href="lib/mocha/mocha.css"> </head> <body> <script src="lib/mocha/mocha.js"></script> <script src="lib/chai/chai.js"></script> <script>mocha.setup('bdd')</script> <div id="mocha"> </div> <script> mocha.run(); </script> </body> </html>
You can use chai to run unit tests in NodeJS application by including chai and using mocha to run tests
# Include this in the script you need to debug var chai = require('chai')
References:
- https://www.sitepoint.com/debugging-javascript-projects-vs-code-chrome-debugger
- https://www.sitepoint.com/unit-test-javascript-mocha-chai