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

Jest async test using `done` callback syntax doesn't work with autoPreview: true

Open jmasukawa opened this issue 1 year ago • 1 comments

Describe the bug

When jest-preview's autoPreview: true: Using Jest's done callback syntax to write an asynchronous test (Jest documentation), the test fails because done is undefined.

With autoPreview: false, there is no issue.

Screenshots

image

Reproduce

Forked the official jest-preview stackblitz demo, then used the done async syntax in App.test.tsx, and the bug appears.

Repro: https://stackblitz.com/edit/jest-preview-zfv89j?file=src%2FApp.test.tsx

Expected behavior

With autoPreview: true, done callback should be defined, and will end the test when called.

Environment (please complete the following information)

  • OS: macOS 14.4.1
  • Browser: Chrome
  • Jest version: 27.5.1 (can also repro the bug in a private project on jest 29.7.0)

Additional context

The issue feels like it's around where the Jest it function is patched for autoPreview, here: https://github.com/nvh95/jest-preview/blob/880630f4165a55a7e2cced981b1275e32416e5ee/src/configure.ts#L80-L102

jmasukawa avatar Apr 16 '24 18:04 jmasukawa

similarly, it.failing will also be broken 😢

chrispyliang avatar Mar 25 '25 19:03 chrispyliang

@jmasukawa @chrispyliang Fixed in #325

released in https://www.npmjs.com/package/jest-preview/v/0.3.2-alpha.3

I will release 0.3.2 soon

nvh95 avatar Sep 07 '25 18:09 nvh95

v0.3.2 is out https://github.com/nvh95/jest-preview/releases/tag/v0.3.2

nvh95 avatar Sep 07 '25 18:09 nvh95

Thank you for addressing!

jmasukawa avatar Sep 17 '25 20:09 jmasukawa