-
Notifications
You must be signed in to change notification settings - Fork 45
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
Can I use "synthetic default imports" in TypeScript with Wallaby and Jest? #1181
Comments
This one is interesting. In TypeScript compiler itself, the However, Note you'll obviously need to setup a similar babel compilation for your production build, otherwise your app's tests with Jest/Wallaby will work, but your prod build will not work if it's only using TypeScript compiler. If you don't mind this magic from
Here's how the change may look like: module.exports = function (wallaby) {
return {
...
compilers: {
'**/*.ts?(x)': wallaby.compilers.typeScript({
module: 'es2015'
})
},
preprocessors: {
'**/*.js': file => require('babel-core').transform(
file.content,
{sourceMap: true, plugins: ['transform-es2015-modules-commonjs']})
},
...
}
}; Hope it makes sense. |
Thanks, Artem! I confirmed that your suggested changes solved the problem, and that the production build didn't work, as you said. On a previous project, we were running the Typescript through Babel so having "allowSyntheticDefaultImports" didn't cause us a problem and solved some issues for us importing certain modules. This time I'd like to see if I can get away without Babel, so I think I'll turn that flag off for now and use the longer import style. |
I'm finding that my tests won't work in Wallaby if I use module imports like
import React from 'react';
. I have to useimport * as React from 'react';
. The former does work when I run the tests in Jest. Is there a way I can tweak my config to make this work?Wallaby.js configuration file
tsconfig
Jest config in package.json
Code editor or IDE name and version
Visual Studio 2017
The text was updated successfully, but these errors were encountered: