twenty/packages/twenty-shared/jest.config.mjs
Paul Rastoin 0fdc7ba834
Twenty-shared tests parses decorator (#15765)
## Introduction
Since we've moved some class validator instances from twenty-server to
twenty-shared tests are red because they do not know how to parse
decorators declarations

We've fixed this by explicitly installing `class-validator` in
`twenty-shared` and configuring jest swc accordingly

## Twenty-server class validator patch
I don't even know if that's something we need anymore
Seems to be a patch either fixing or introducing credit card and phone
number validation
Would prefer discussing the need or not to either before merging this as
it could introduce regression at runtime:
- Centralize the patch to be consumed in both `twenty-server` and
`twenty-shared`
- Remove the patch

We should also document every patch motivations we do as it's quite
though to iterate over a such huge one
2025-11-13 16:06:04 +00:00

51 lines
1.2 KiB
JavaScript

const jestConfig = {
silent: true,
displayName: 'twenty-shared',
preset: '../../jest.preset.js',
testEnvironment: 'jsdom',
transformIgnorePatterns: ['../../node_modules/'],
transform: {
'^.+\\.[tj]sx?$': [
'@swc/jest',
{
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
decorators: true,
},
transform: {
react: { runtime: 'automatic' },
decoratorMetadata: true,
},
},
},
],
},
moduleNameMapper: {
// TODO prastoin investigate not working with pathsToModuleNameMapper
/*
{
'^@/(.*)\\.js$': './src/$1',
'^@/(.*)$': './src/$1',
'^(\\.{1,2}/.*)\\.js$': '$1'
} // use esm true
{ '^@/(.*)$': './src/$1' } // useEsm false
*/
'/^@/(.*)$/': './src/$1',
'\\.(jpg|jpeg|png|gif|webp|svg|svg\\?react)$':
'<rootDir>/__mocks__/imageMockShared.js',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
coverageDirectory: './coverage',
coverageThreshold: {
global: {
statements: 80,
lines: 90,
functions: 75,
},
},
};
export default jestConfig;