Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

● Test suite failed to run @Table annotation is missing on class "API" #1722

Open
odeyemiibukunajewole opened this issue May 2, 2024 · 1 comment

Comments

@odeyemiibukunajewole
Copy link

Hello , Im writing a jest test for my application writting in typescript

Any time a mocked the Model class this way ,

jest.mock("@apps/apim/entities/server.entity");
jest.mock("@apps/apim/entities/api.entity");

I got this error

apps/apim/tests/unit/services/endpoint.service.test.ts
● Test suite failed to run

@Table annotation is missing on class "EndPoint"

  4 | import { glob } from "glob";
  5 |
> 6 | const sequelize = new Sequelize({
    |                   ^
  7 |   dialect: "mysql",
  8 |   // sync: { force: true },
  9 |   // sync: { alter: true },

  at node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.js:68:23
      at Array.map (<anonymous>)
  at Sequelize.defineModels (node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.js:61:23)
  at Sequelize.addModels (node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.js:37:36)
  at new Sequelize (node_modules/sequelize-typescript/dist/sequelize/sequelize/sequelize.js:20:22)
  at Object.<anonymous> (libs/core/database/index.ts:6:19)
  at Object.<anonymous> (apps/apim/services/api.service.ts:17:1)
  at Object.<anonymous> (apps/apim/services/endpoint.service.ts:8:1)
  at Object.<anonymous> (apps/apim/__tests__/unit/services/endpoint.service.test.ts:5:1)

this is my table
@table({ modelName: 'apim_api' })
export default class API extends Model {
@column({
type: DataType.UUID,
primaryKey: true,
defaultValue: DataType.UUIDV4,
})
id: string;

@ForeignKey(() => Category)
@Column({ type: DataType.UUID, allowNull: false })
category_id: string;
@Bodokh
Copy link

Bodokh commented May 19, 2024

Having the same issue here. Driving me nuts, works when running the app, but getting that same error every time i run tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants