jest
jest copied to clipboard
feat(snapshot): support snapshotResolver and snapshotSerializers written in ESM
Summary
Part of #11167.
See the discussion on the snapshotResolver and snapshotSerializers config: https://github.com/facebook/jest/issues/11167#issuecomment-953569252 https://github.com/facebook/jest/issues/11167#issuecomment-953585698
Test plan
Integration test added.
@chentsulin I wonder if this could be finalized or if it is waiting for a re-review from @SimenB ?...
We need this here: https://github.com/Maxim-Mazurok/google-api-typings-generator/blob/062854a2021be2dd244855261a73f5172bf597c2/custom-resolver.cjs for the use-case of using one snapshot file per test.
Thank you!
Main issue is that we load the resolver within the tests (https://github.com/facebook/jest/pull/12014#discussion_r739624598), which means it's pretty much blocked by full ESM support
Ah, I see, thank you for the update, we are re-considering our approach now. Cheers!
It might make sense to not load it within, but that means people who have written it in TS or something that requires transpilation will fail. So not sure which tradeoff is the best here
It's been a year. Any updates?
This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.
It's been another year. Any updates?
Could this PR be rebased so we can merge it for Jest 30?
Following up my old comment - I think we can just load the resolver outside of the tests. That gives ESM support, and if people wanna write it in TS they can use https://nodejs.org/en/learn/typescript/run-natively