jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: Jest does not recognise Vite suffixes applied to imports

Open njoel24 opened this issue 1 year ago • 1 comments

Version

29

Steps to reproduce

With Vite we can decide how to import static assets: https://vitejs.dev/guide/assets . In particular: you can add specific suffixes to the imported file, like ?inline.

Jest 29 does not recognize those imports and throws an error saying that the file could not be found.

If I use a moduleMapper I can map the file to a stub, but existing transforms they do not work any longer..

Expected behavior

File should have been recognize and Jest should threat the suffix not as as part of the path, but instead as metadata or ignore it vcompletely. I should be able to use a transform if in order to treat svg as ReactComponent for example.

Actual behavior

Jest says that the file is not found, so the related transform is not applied

Additional context

No response

Environment

OS: Windows
Jest Version: 29
Node version: 18

njoel24 avatar Feb 16 '24 14:02 njoel24

you can use a custom resolver to strip query parameters. not sure if there are cleaner ways of doing it

SimenB avatar Feb 16 '24 17:02 SimenB

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Mar 17 '24 18:03 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Apr 16 '24 18:04 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

github-actions[bot] avatar Apr 16 '24 18:04 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar May 18 '24 00:05 github-actions[bot]