Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with jest-preview/transforms/file when use with ts-jest to process .tsx files #163

Closed
nvh95 opened this issue Jun 26, 2022 · 0 comments · Fixed by #178
Closed

Issue with jest-preview/transforms/file when use with ts-jest to process .tsx files #163

nvh95 opened this issue Jun 26, 2022 · 0 comments · Fixed by #178

Comments

@nvh95
Copy link
Owner

nvh95 commented Jun 26, 2022

Describe the bug
Cannot see images if we use ts-jest to process .tsx files
broken image in Jest Preview Dashboard

Demo video: https://youtu.be/rkgSxUaFfnY?t=502

To Reproduce

git clone https://github.com/jellydn/react-tips-2022-demo
cd react-tips-2022-demo
git checkout 973357373b2ea6fdc629e4b11872eb99951daed9
yarn 
yarn jest-preview
yarn test

Expected behavior
Should see the image

Additional context

When inspecting the cache of Jest Code Transformation for SVG using ts-jest, it looks like this
Screen Shot 2022-06-27 at 01 09 04
If I switch to @swc/jest, it looks like this:
Screen Shot 2022-06-27 at 01 04 22

The difference is that @swc/jest use _interopRequireDefault to import the file in both CommonJS and ES Modules cases. So this is likely the issue comes from ts-jest. (But it's ok since before jest preview, we do not care about SVG files in Jest)

Possible solutions

  1. Open an issue/ Send a PR to ts-jest to include _interopRequireDefault (or similar)
  2. Switch to other code transformers such as @swc/jest.

1 should be the correct fix. However, users can workaround using 2 when 1 is not ready yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant