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

deepUnmock doesn't work well with ts-jest@24 #1098

Closed
hojovi opened this issue May 13, 2019 · 2 comments
Closed

deepUnmock doesn't work well with ts-jest@24 #1098

hojovi opened this issue May 13, 2019 · 2 comments

Comments

@hojovi
Copy link

hojovi commented May 13, 2019

Issue :

deepUnmock doesn't work on ts-jest@24

Expected behavior :

deepUnmock should work on ts-jest@24

Debug log:

log file content
# content of ts-jest.log :
No content

Minimal repo :

https://github.com/hojovi/jest_test_failure
The tests successes in ts-jest@23 but fails in ts-jest@24.

@tonyhallett
Copy link
Contributor

tonyhallett commented Dec 8, 2019

prior to this commit 04ab3de , after the typescript had been transformed the transformed source was then passed to babel for an addition transform if you did not explicitly skip this step with skipBabel This would have performed hoisting.

This has now been changed to opt in. ts-jest does attempt to port from the old method to the new but it only works for skipBabel = false.

There is now the concept of presets in jest. ts-jest presets help configure the transform. Although one of these presets is called jsWithBabel it is not what now controls babel hoisting.

For that you need to set the globals/ts-jest/ babelConfig property. In the case of your example repo setting this to true would have resulted in hoisting of deepUnmock.

Babel Config option
ts-jest by default does NOT use Babel. But you may want to use it, especially if your code rely on Babel plugins to make some transformations. ts-jest can call the BabelJest processor once TypeScript has transformed the source into JavaScript.

The option is babelConfig and it works pretty much as the tsConfig option, except that it is disabled by default. Here is the possible values it can take:

false: the default, disables the use of Babel

true: enables Babel processing. ts-jest will try to find a .babelrc, .babelrc.js file or a babel section in the package.json file of your project and use it as the config to pass to babel-jest processor.

{ ... }: inline Babel options. You can also set this to an empty object ({}) so that the default Babel config file is not used.

Note that ts-jest does now do hoisting but it does not currently hoist deepUnmock. See my comment

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 5, 2020

Closes via #1372

@ahnpnl ahnpnl closed this as completed Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants