Description
The README.md gives me the impression that debugging of tests is possible with the --serial option. It looks like this option is designed for debugging ava itself though.
I tried debugging tests in the following way:
-
ava --init
-
npm install signal-exit
-
Based on add covenience util for debugging #225, put the following code in
node_modules/ava/debug.js
#!/usr/bin/env node 'use strict'; var onExit = require('signal-exit'); var chalk = require('chalk'); process.send = function (data) { console.dir(data); }; onExit(function () { process.emit('ava-cleanup', true); }); require('./lib/babel');
-
Make a simple test with a debugger keyword:
import test from 'ava'; test(t => { debugger; t.same([4, 2], [1, 2]); });
-
node debug node_modules/ava/debug.js " {\"file\":\"path/to/test.js\",\"failFast\":false,\"serial\":true,\"require\":[]} "
When running this via the node debugger (or node inspector) the breakpoint is not triggered, possibly due to the code transformations via babel.
Since ava spawns new processes, debugging cli.js directly is not possible. The new node processes try to listen to the same debug port and thus crash with EADDRINUSE :::5858
. By hacking fork.js and adding options['execArgv'] = ['--debug-brk=5860'];
I could attach node inspector to this port but it still failed to trigger my breakpoint within the test.
Is there any way to use a debugger for my tests?