Closed mcmxcdev closed 1 year ago
It appears that the ui
project is still configured to use ts-jest
which is the cause of that error. Could you post the jest.config.ts
?
It appears that the
ui
project is still configured to usets-jest
which is the cause of that error. Could you post thejest.config.ts
?
Searching through the whole project, there is no reference to ts-jest
anymore.
jest.config.ts
export default {
displayName: 'shared-ui',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.(t|j)sx?$': [
'@swc/jest',
{
jsc: {
transform: {
react: {
runtime: 'automatic',
},
},
},
},
],
},
coverageDirectory: '../../../coverage/libs/shared/ui',
setupFilesAfterEnv: ['../../../jest.setup.js'],
};
jest.preset.js
const nxPreset = require('@nrwl/jest/preset').default;
module.exports = {
...nxPreset,
moduleFileExtensions: ['js', 'ts', 'tsx', 'html'],
moduleNameMapper: {
'@next/font/(.*)': require.resolve(
'next/dist/build/jest/__mocks__/nextFontMock.js'
),
},
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'jest-extended/all',
],
restoreMocks: true,
testTimeout: 60000,
};
jest.setup.js
is not relevant, since it just uses mocks.
The default nx preset contains ts-jest as the default transformer. Most likely jest is validating that first even though it's never used. Try deleting the transformer property on the nx preset in the root jest.preset.js file and see if it goes away.
Good catch! It starts working when I do:
...nxPreset,
transform: undefined,
so @nrwl/jest/preset
code needs to be updated to not hard require ts-jest
While I do see that it would work best for you to not have the preset define a default transformer, it's the job of the nx jest preset to define the default behaviors so I don't think we plan on changing the preset.
Since removing the default transformer for you workspace works, I'm going to find this as a valid work around for anyone else wanting to do this.
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.
Current Behavior
We recently switched from
ts-jest
to@swc/jest
and would now like to get rid ofts-jest
dependency.When uninstalled, we run into this error:
Expected Behavior
It should be fine to use whatever tool for test transformation without being restricted by validation errors.
GitHub Repo
No response
Steps to Reproduce
ts-jest
from nx monorepoNx Report
Failure Logs
No response
Additional Information
No response