Debugging in Jest

Add breakpoint in test:

1
2
3
4
5
6
7
8
  it.each`
    a    | b    | result
    ${1} | ${2} | ${3}
    ${0} | ${4} | ${4}
  `("should return $result when a = $a, b = $b", ({ a, b, result }) => {
    debugger; // breakpoint
    expect(sum(a, b)).toBe(result);
  });

Run this following command:

1
node --inspect-brk ./node_modules/.bin/jest ./<file_of_test>.test.js

Subscribe to the newsletter

Get a once-per-week email with my latest content. By subscribing to this newsletter you will also be the first to receive last updates of my eBooks and courses.

0 members

Comments 💬