nvh95 / jest-preview

Debug your Jest tests. Effortlessly.🛠🖼
https://www.jest-preview.com
MIT License
2.34k stars 76 forks source link

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

Open jmasukawa opened 6 months ago

jmasukawa commented 6 months ago

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)

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