Closed AhmedBHameed closed 3 years ago
I guess I found a workaround solution.
I moved setupTests.ts
to test
folder and use next.config.js
to ignore test
folder completely.
That will prevent cheking test folder while building the app which make sense as long it is related to testing only
module.exports = {
publicRuntimeConfig: {
mapboxApiAccessToken:
'pk.eyJ1IjoiYWhtZWRiaGFtZWVkIiwiYSI6ImNrNmNpd3M3ZzExZXMza21neGoxNHJoeDcifQ.07EbC691qPVJ86uLhJyfWA',
domain: `${
process.env.NODE_ENV === 'production'
? 'https://www.ahmedhameed.dev'
: 'http://localhost:5000'
}`,
graphqlApi: '/nodeys/v1/graphql',
uploadApi: '/nodeys/api/upload',
localeSubpaths:
typeof process.env.LOCALE_SUBPATHS === 'string'
? process.env.LOCALE_SUBPATHS
: 'none',
},
i18n: {
locales: ['en', 'ar'],
defaultLocale: 'en',
localeDetection: false,
},
images: {
domains: ['assets.vercel.com'],
},
webpackDevMiddleware: (config) => {
config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
};
return config;
},
webpack: (config, {webpack}) => {
config.plugins.push(new webpack.IgnorePlugin(/\/__tests__\//));
config.plugins.push(new webpack.IgnorePlugin(/\/test\//)); // <<<<<====== This line solved my issue
config.node = {
fs: 'empty',
};
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
return config;
},
};
Closing my issue.
Describssion:
I have a project here works perfectly in development mode but when I'm trying to build, I'm getting the following error:
I'm not sure if this error from my configuration of the unit test! but since it was pointing to
react-testing-library
, I wanted to post the issue here and check for some suggestions.Background:
I used
next.js
v9 before and now I wanted to add few features so i ended up with updating next library to v10 with adding unit test configuration.package.json
jest.config.js
.babelrc
next.config.js