test: add TypeScript module specs to examples #3963
Draft
+493
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is to show existing support for TypeScript modules.
Summary
Per #3954, I'm adding example specs with the
.mts
extension.This is based on ts-jest's documentation and existing code.
Test plan
npm run test-examples
I manually inspected to confirm each of the configuration files this PR touches runs two different spec files: the existing one and the new TypeScript module file.
Does this PR introduce a breaking change?
Other information
Questions on this patch for reviewers, because I'm unfamiliar with this code base:
['ts-jest', ...]
? The type definition says it could beTransformerConfig
, which is just[string, ...]
. I am specifically asking because it differs from thepreset
field in most of these changes.preset
andtransform
in the documentation. I see some of these examples already do this, but I'm making it happen here across all of them. What's the right way to handle this?mjsResolver
's type. When I tried to include it in the TypeScript file, jest-resolve gave me many errors. I tried adding a .d.ts file (which led to linting errors), and renaming it to .mts. Finally, I just put it in as a void string expression, which is a Dirty Hack. I'd like a better fix, so that we can do proper type checking on the resolver. As code documentation, though, it's better than nothing.