aelbore / esbuild-jest

A Jest transformer using esbuild
518 stars 51 forks source link

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

Open semoal opened 3 years ago

semoal commented 3 years ago

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!

peterp commented 3 years ago

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