jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.12k stars 6.44k forks source link

feat(jest-config):Support loading TS config files via docblock loader #15190

Closed k-rajat19 closed 2 months ago

k-rajat19 commented 2 months ago

Summary

Unblocks #13143 Unblocks #11989

Added support for loading Typescript configuration files by specifying a loader in a docblock comment in config file. this is a continuation of work done in #13742 one can define a loader in a docblock comment like this:

/**@jest-config-loader ts-node(or esbuild-register)*/

import type {Config} from 'jest';

const config: Config = {
  verbose: true,
};

export default config;

if there is no loader defined it uses ts-node by default for loading a config file. currently there is support for esbuild-register and ts-node.

Test plan

Added e2e tests

netlify[bot] commented 2 months ago

Deploy Preview for jestjs ready!

Name Link
Latest commit 4d71390b923ab71854688df4e34a19e0a3c54395
Latest deploy log https://app.netlify.com/sites/jestjs/deploys/669f622d772cf40008556d1b
Deploy Preview https://deploy-preview-15190--jestjs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

SimenB commented 2 months ago

Thanks for sending a PR!

this PR also opt-out using ts-node by default which was initially set as a default loader for loading ts configs (https://github.com/jestjs/jest/issues/13143#issuecomment-1374565096) So Jest will not do anything by default for loading ts configs, one has to define a loader in a docblock comment like this:

I think we should change default behaviour in a separate PR, just to keep the scope per PR down a bit

k-rajat19 commented 2 months ago

I think we should change default behaviour in a separate PR, just to keep the scope per PR down a bit

Should I update docs in a separate PR ? after current one and PR which changes default behaviour lands or in this one according to current changes :)

SimenB commented 2 months ago

Updating the docs here with info about the docblock makes sense. Even though we might delete parts of the new docs when changing default behaviour 🙂

SimenB commented 1 month ago

https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.6

github-actions[bot] commented 1 week ago

This pull request 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.