Debugging Tests
You can debug your tests using IDE’s built-in debugging tools. This allows you to set breakpoints, inspect variables, and step through your code to identify issues.
WebStorm
To debug your tests in WebStorm, follow these steps:
- Open
Run/Debug Configurationsin WebStorm. - Click on the
+icon to add a new configuration. - Select
Node.jsfrom the list. - In the
Filefield, add the following:node_modules/@olton/latte/cli/latte.js. - In the
Application parametersfield, add your enable debug option:--debug. If you need to pass any other parameters. For example:--debug --dom. - In the
Working directoryfield, set the path to your project directory. - Click
OKto save the configuration. - Add command
debuggerin your test files where you want to pause execution.
describe(`Array tests`, () => { it('toBeArray [] == []', () => { debugger return expect([]).toBeArray() })})Now you can run the debugger by selecting the configuration you created and clicking the Debug button. The execution will pause at the debugger statement, allowing you to inspect variables and step through your code.
Visual Studio Code
To debug your tests in VSC, follow these steps:
- Open the
Run and Debugpanel in VSC (Ctrl+Shift+). - Click on
create a launch.json file. - Select
Node.jsfrom the list. - In the
programfield, add the following:${workspaceFolder}/node_modules/@olton/latte/cli/latte.js. - In the
argsfield, add your enable debug option:--debug. If you need to pass any other parameters. For example:--debug --dom. - In the
cwdfield, set the path to your project directory. - Click
OKto save the configuration. - Add command
debuggerin your test files where you want to pause execution. - Now you can run the debugger by selecting the configuration you created and clicking the
Runbutton. The execution will pause at thedebuggerstatement, allowing you to inspect variables and step through your code.
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Debugging Tests", "program": "${workspaceFolder}/node_modules/@olton/latte/cli/latte.js", "args": ["--debug"], "cwd": "${workspaceFolder}" } ]}