After updating from [email protected] many tests fail with TypeError: Cannot read property 'configure' of undefined
it seems to be happening at Enzyme.configure({ adapter: new enzymeAdapterReact16() });
import Enzyme, { shallow } from 'enzyme';
import enzymeAdapterReact16 from 'enzyme-adapter-react-16';
import React from 'react';
import TaskMenuCall, { TaskMenuCallProps } from './TaskMenuCall';
Enzyme.configure({ adapter: new enzymeAdapterReact16() });
const getDefaultProps = (): TaskMenuCallProps & { onClick: jest.Mock } => ({
onClick: jest.fn(),
phones: [{ label: 'mobile', phone: '3521231234' }, { label: 'office', phone: '3525675678' }],
});
describe('TaskMenuCall component', () => {
it('shallow renders without crashing', () => {
const props = getDefaultProps();
shallow(<TaskMenuCall {...props} />);
});
});
Test keep running successfully
# content of ts-jest.log :
btw, I tried using "esModuleInterop": true, but that breaks all sorts of other stuff.
I have a simular problem. After update [email protected] to @23.10.4 many tests fail with TypeError: Cannot read property 'register' of undefined
import Validator from 'validatorjs'
...
Validator.register(
'only_numbers',
CustomValidations.CustomOnlyNumbers.validate,
CustomValidations.CustomOnlyNumbers.errorMessage
)
...
It was working before update.
hi @moonray, would you please provide us a sample repo with yourjest and ts-jest setup together with the example test case ?
I have the same issue with
TypeError: Cannot read property 'createElement' of undefined
so apparently React is not being loaded (which is my first import).
This happens on ts-jest 23.10.4 and 23.10.5.
Downgrading to 22.0.4 fixed the issue.
Same issue here
Repo can be found here: ts-jest-884
Is anything else needed?
Same issue here.
I have the same issue
minimal repo has been linked, but nobody is looking at this. There doesn't seem to be a way to remove the label.
Same issue here, it seems some class with static method not been compiled
Same issue with @types/[email protected], [email protected], and [email protected]
I was running into this issue with ts-jest as well (introduced with [email protected], but also observed with [email protected]). It took me a while to figure out (even though @moonray hinted at it in https://github.com/kulshekhar/ts-jest/issues/884#issuecomment-440762348) that this is caused by an intentionally breaking change introduced in 23.0.0 via https://github.com/kulshekhar/ts-jest/pull/503.
Adding "esModuleInterop": true to my compilerOptions in tsconfig.json fixed the problem. I think it's also worth noting that adding that compiler option to the minimal repo linked in https://github.com/kulshekhar/ts-jest/issues/884#issuecomment-462357593 fixes the tests in the minimal repo.
Given that:
1) this has affected several people
2) there is no 23.0.0 entry in the changelog
3) the 23.0.0 release doesn't mention this breaking change
I wonder if it makes sense to add a warning or note or something to point users in the direction of "esModuleInterop": true? (I say this while noting that it has caused issues for others: https://github.com/kulshekhar/ts-jest/issues/884#issuecomment-440762348.)
maybe CHANGELOG.md of v23.0.0 should include this and point to the PR ?
hi this is not ts-jest issue. This is related to how to use enzyme, react with typescript. Please check this post for your issue.
Most helpful comment
I have the same issue with
so apparently React is not being loaded (which is my first import).
This happens on ts-jest 23.10.4 and 23.10.5.
Downgrading to 22.0.4 fixed the issue.