Debugging in Jest

Add breakpoint in test:

  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:

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

About

My name is Max, also known as @mxkvl.

I am a software developer, currently working mostly with TypeScript, React and Node ecosystems.

I write a blog about topics that interest me most: programming languages in general, TypeScript, testing, writing and other great stuff.

Join the Mailing List