Simple React Todo Application
In order to jsdom to works, se need to mock the matchMedia
. Need to add script on setupTests.js
Object.defineProperty(window, 'matchMedia', {
value: () => {
return {
matches: false,
addListener: () => { },
removeListener: () => { }
};
}
});
Add below to package.json
tp ensure the antd can works with testing.
{
"jest": {
"transformIgnorePatterns": [
"/node_modules/(?!antd|@ant-design|rc-.+?|@babel/runtime).+(js|jsx)$"
],
}
}
Add below to package.json
to ensure the test Jest mock / jest.fn()
can works
{
"jest": {
"resetMocks": false
}
}
Ref: jestjs/jest#9131