esbuild-jest icon indicating copy to clipboard operation
esbuild-jest copied to clipboard

`Jest: Couldn't locate all inline snapshots` when empty to match inline snapshot

Open semoal opened this issue 3 years ago • 1 comments

Hello folks!

I've tried to use this plugin with inline snapshoting and I've get this error, probably it's related to the compiled code by esbuild, Jest can't find where it's the code located, but I'm not sure how to debug it.

Do you have any clues or guidance, I can help fixing the bug =)

I've modified one of your examples

it("should render", () => {
  render(<App />, element);
-  expect(element.innerHTML).toMatchInlineSnapshot(`"<div>hello world!</div>"`)
+  expect(element.innerHTML).toMatchInlineSnapshot()
});
 FAIL  tests/react-ts.spec.tsx
  ● Test suite failed to run

    Jest: Couldn't locate all inline snapshots.

      at Object.parse (node_modules/jest-snapshot/build/InlineSnapshots.js:267:11)

And the test's fails, I've tried to replace esbuild-jest by the standard babel implementation and works correctly!

semoal avatar May 06 '21 16:05 semoal

You have to generate sourcemaps, in my opinion this should be the default: https://github.com/aelbore/esbuild-jest#setting-up-jest-config-file-with-transformoptions

peterp avatar Jul 22 '21 19:07 peterp