-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
transformIgnorePatterns does not work with Ionic 6 and Jest #9640
Comments
I don't really know what's going on here. I got it to work by using ts-jest and removing the @nrwl/react/plugins/jest transformer. but that's because it transforms everything under the sun and really slows down the tests. not ideal. I'm not sure if I'm just completely missing something (probably am) but I can still see the files being transformed that should be ignored. my only guess is something about the ignore pattern is wrong, but it matches all the other ones, or something about the react plugin is causing issues that I'm not seeing. "working" configuration module.exports = {
displayName: 'ionic',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
}
},
transform: {
// '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest', // this seems to be angry when having it. no idea why
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/ionic',
// From https://ionicframework.com/docs/intro/upgrading-to-ionic-6#testing
transformIgnorePatterns: [
'/node_modules/(?!@ionic/core|@stencil/core|ionicons)',
],
}; |
reading more on the ionic 6 testing page. there is this line
when moving the nrwl/react/babel preset to the root config and removing the nrwl/react jest plugin it works. hopefully that's enough info to get you at least unblocked @seanaguinaga I'm going to keep digging to see what is happening here. |
So I talked with some coworkers and it looks like babel isn't transforming the code within the node_modules directory because there only babel config it finds is the babel.config.json which doesn't contain any presets about how to transform the code. so the transform just spits out the same (ESM) code that was provided to it. I assume this is why the ionic docs said to update the project-wide configuration vs the file relative project. forcing babel-jest to use your file relative config will work, but babel docs suggest not doing this. I don't directly see any harm in doing this because it's only for tests. '^.+\\.[tj]sx?$': ['babel-jest', {configFile: path.resolve(__dirname, '.babelrc')}] in your jest config transformers. I'm going to talk with some other coworkers to see if they know of any unintended side effects of putting the preset in the root config would do. I presume it would be okay but I can imagine odd transform behaviors happening if your repo requires vastily different presets. hopefully that provides some insight into your issue @seanaguinaga |
@seanaguinaga
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic"
}
]
]
'^.+\\.[tj]sx?$': ['babel-jest', {configFile: path.resolve(__dirname, '.babelrc')}] though I think you'll run into issues with cross library support if the other libs require a different babel config. The second issue you'll run into after getting the preset working is Hopefully, that helps you move forward with this issue. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Repro:
https://github.com/seanaguinaga/nx-jest-ionic-repro
Any ideas?
The text was updated successfully, but these errors were encountered: