Here is the error i get when trying to run the tests:
` ● Test suite failed to run
@Table annotation is missing on class "GroupPolicies"
6 | import * as models from './models';
7 | // @ts-expect-error sequelize defition is valid
> 8 | export const sequelize = new Sequelize({
| ^
9 | dialect: 'postgres',
10 | models: Object.values(models).filter((model) => model instanceof Function),
11 | pool: {
at node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.js:67:23`
It works perfectly when running the server with tsx and also after building for production sequelize works. But when using jest the tests fail.
Here is my jest config
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src', '<rootDir>/tests'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
transform: {
'^.+\.(ts|tsx)$': 'ts-jest',
},
clearMocks: true,
collectCoverage: true,
coverageDirectory: 'coverage',
testPathIgnorePatterns: ['/lib/', '/node_modules/', '/img/', '/dist/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
modulePaths: ['<rootDir>/src'],
moduleDirectories: ['node_modules'],
};
GroupPolicies:
@Table({ tableName: 'group_policies', timestamps: false })
export class GroupPolicies
extends Model<GroupPoliciesAttributes, GroupPoliciesAttributes>
implements GroupPoliciesAttributes
{
@Column({ primaryKey: true, type: DataType.INTEGER })
@Index({ name: 'group_policies_pkey', using: 'btree', unique: true })
group_id!: number;
// .... rest of code
I tried isolating the models and passing only 1 model still same error.
I tried running the tests with docker which at some point worked but now does not work.