Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using "ts-jest" package name directly #361

Closed
martijnthe opened this issue Nov 5, 2017 · 4 comments
Closed

Enable using "ts-jest" package name directly #361

martijnthe opened this issue Nov 5, 2017 · 4 comments

Comments

@martijnthe
Copy link
Contributor

martijnthe commented Nov 5, 2017

  • Issue

I would like to be able to:

  "jest": {
    "transform": {
      "^.+\\.tsx?$": "ts-jest"
    },

Trying this today leads to:

    TypeError: Jest: a transform must export a `process` function.

The fix is easy, just export a process property that points to the preprocessor function from index.ts.

In general, I don't think assuming that <rootDir>/node_modules/ts-jest/preprocessor.js exists is a good idea.
For example, when using lerna packages might get hoisted to a node_modules of parent directory.

FWIW, it's possible to use "babel-jest" like this.

  • Expected behavior

See above.

  • Link to a minimal repo that reproduces this issue

See above.

  • Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo

N/A

@kulshekhar
Copy link
Owner

kulshekhar commented Nov 6, 2017

I think Jest requires that property to point to a javascript file. Is that not the case?

martijnthe pushed a commit to martijnthe/ts-jest that referenced this issue Nov 6, 2017
This way, the `"ts-jest"` package name can be used as Jest transform, instead of specifying the path to preprocessor.js.
The latter did not work when the ts-jest package had been hoisted to a parent folder (for example by lerna).

Fixes kulshekhar#361
martijnthe pushed a commit to martijnthe/ts-jest that referenced this issue Nov 6, 2017
This way, the `"ts-jest"` package name can be used as Jest transform, instead of specifying the path to preprocessor.js.
The latter did not work when the ts-jest package had been hoisted to a parent folder (for example by lerna).

Fixes kulshekhar#361
martijnthe pushed a commit to martijnthe/ts-jest that referenced this issue Nov 6, 2017
This way, the `"ts-jest"` package name can be used as Jest transform, instead of specifying the path to preprocessor.js.
The latter did not work when the ts-jest package had been hoisted to a parent folder (for example by lerna).

Fixes kulshekhar#361
martijnthe pushed a commit to martijnthe/ts-jest that referenced this issue Nov 6, 2017
This way, the `"ts-jest"` package name can be used as Jest transform, instead of specifying the path to preprocessor.js.
The latter did not work when the ts-jest package had been hoisted to a parent folder (for example by lerna).

Fixes kulshekhar#361
martijnthe pushed a commit to martijnthe/ts-jest that referenced this issue Nov 6, 2017
This way, the `"ts-jest"` package name can be used as Jest transform, instead of specifying the path to preprocessor.js.
The latter did not work when the ts-jest package had been hoisted to a parent folder (for example by lerna).

Fixes kulshekhar#361
@martijnthe
Copy link
Contributor Author

martijnthe commented Nov 6, 2017

@kulshekhar: no it can also be a package name.
I opened a PR to implement this change: #363

@kulshekhar
Copy link
Owner

Reopening as the PR for this was reverted due to #367

@kulshekhar kulshekhar reopened this Nov 8, 2017
@kulshekhar
Copy link
Owner

Fixed in #373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants