question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support typescript format configuration file

See original GitHub issue

🚀 Feature Proposal

To be able to fully use TypeScript

Motivation

Make the .js file not appear in the project.

Example

This allows us to TypeScript ONLY.

Expected:

// File path: project/jest.config.ts
import { Configuration } from "jest";
import { defaults } from "jest-config";

const configure: Configuration = {
    preset: 'ts-jest',
    testEnvironment: 'jest-environment-jsdom-fourteen',
    globals: {
        'ts-jest': {
            isolatedModules: true,
        },
    },
    moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
}

export default configure

Pitch

Why does this feature belong in the Jest core platform?

Common feature proposals that do not typically make it to core:

  • New matchers (see jest-extended)
  • Changes to the default reporter (use custom reporters instead)
  • Changes to node/jsdom test environments (use custom environments instead)

Reference

https://github.com/kulshekhar/ts-jest/issues/1415

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:26
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

20reactions
glennreyescommented, Sep 3, 2020

I don’t think this is worth it. Jest runs on Node and requires your config file using Node. For jest to support .ts config files it would need to transpile it and then run it, which you could do yourself very easily if you really need a Typescript configuration file.

Although jest handles transpilation very well thanks to babel-jest and Babel, it does so in the tests once jest if fully configured, loaded and up and running. Having to do this transpilation just to read the configuration file can be both difficult or cumbersome to implement and result in a slower setup.

I just haven’t seen and can’t think of a project that needs a jest configuration so complex that type checking for it becomes necessary. Jest already supports complex scenarios like monorepos very well with relatively simple configurations. The fact that you use and like typescript doesn’t mean you have to use it in every single line of code and every file must be a .ts file.

I disagree. To me it’s a huge win if I can get a fully typed configuration without ever having to look up the documentation for every single option anymore. I’d rather have auto suggestions popping up in my editor than an X ms faster initial execution.

3reactions
Gamotecommented, Sep 29, 2020

@septs, @nvdnkpr, @G-Rath, @brieb, @dl748, @glennreyes

Hi guys, I hope this is what you were looking for: #10564 ✌️

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Perfect Configuration Format? Try Typescript - Reflect.run
A lot of ink has been spilled about configuration file formats. Popular formats like JSON, TOML, YAML, and XML each have their advantages...
Read more >
Documentation - What is a tsconfig.json - TypeScript
The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file...
Read more >
TypeScript Programming with Visual Studio Code
VS Code includes a TypeScript formatter that provides basic code formatting with reasonable defaults. Use the typescript.format.* settings to configure the ...
Read more >
typescript-formatter | Yarn - Package Manager
help Usage: tsfmt [options] [--] [files...] Options: -r, --replace replace .ts file --verify checking file format --baseDir <path> config file lookup from <path> ......
Read more >
How to create an application-specific config file for TypeScript?
How would I create such a configuration file? In JavaScript, creating config.js and referencing it in the HTML code is a very simple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found