I am trying set up tests with Jest in a create-react-app that is using the override function from customize-cra and react-app-rewired. I have set up a relative path alias and when I run tests it throwing the error cannot find module
here is the code...
// LoginForm.test.js
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import LoginForm from './LoginForm';
it('submits', () => {
const onSubmit = jest.fn();
const { getByText } = render(<LoginForm onSubmit={onSubmit} />);
fireEvent.click(getByText('Log in'));
expect(onSubmit).toHaveBeenCalled();
});
// config-overrides.js
const {
override,
fixBabelImports,
addLessLoader,
addBabelPlugin
} = require("customize-cra");
module.exports = override(
fixBabelImports("import", [
{
libraryName: "antd",
libraryDirectory: "es"
// style: true,
},
{
libraryName: "ant-design-pro",
libraryDirectory: "lib"
// style: true,
}
]),
addBabelPlugin([
"babel-plugin-root-import",
{
rootPathSuffix: "./src"
}
]),
addLessLoader({
javascriptEnabled: true,
modifyVars: {
"@select-item-selected-font-weight": "500",
"@font-family":
'"Futura W01", "Futura", -apple -system, BlinkMacSystemFont, "Segoe UI", sans-serif',
"@pagination-font-family":
'"Futura W01", "Futura", -apple -system, BlinkMacSystemFont, "Segoe UI", sans-serif',
"@statistic-font-family":
'"Futura W01", "Futura", -apple -system, BlinkMacSystemFont, "Segoe UI", sans-serif'
}
})
);
Any pointers much appreciated, thank you.