问题
I just started using Jest. For debugging under testcase file;
describe("Filter function", () => {
test("it should filter by a search", () => {
const input = [
{ id: 1, url: "https://www.google.com" },
{ id: 2, url: "https://www.yahoo.com" },
{ id: 3, url: "https://www.gmail.com" }
];
const output = [{ id: 3, url: "https://www.gmail.com" }];
debugger;
expect(filterByTerm(input, "gmail")).toEqual(output);
debugger;
expect(filterByTerm(input, "GMAIL")).toEqual(output);
});
});
under Project directory - run this command
node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand
After running this command says node --inspect-brk node_modules/jest/bin/jest.js --runInBand Debugger listening on ws://127.0.0.1:9229/ab651461-dfe8-4528-8a07-484a4be5db7b For help, see: https://nodejs.org/en/docs/inspector
after this opened chrome://inspect under it clicked on open dedicated devtools for Node here, It opened window where I added src folder for same and opened test file but debugging didnt came. Help please on same issue
However, in the resulting dev tools window, I can't see anything to debug. I am expecting a process where I can set breakpoints and inspect data.
回答1:
Run this command;
node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand
Debugger listening on ws://127.0.0.1:9229/6a0bb29e-eca2-4a25-b894-a5e803339ec9
For help, see: https://nodejs.org/en/docs/inspector
After this enter this url in chrome;
devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/6a0bb29e-eca2-4a25-b894-a5e803339ec9
and Resume the button on right hand side again Press again F8 wait for some time, Debugging started Like charm..! on your test file where debugger; is written
Thank you again !
来源:https://stackoverflow.com/questions/63671251/unable-to-debug-test-case-using-jest-in-chrome-under-node-devtools