https://cypress.io logo
Any luck using TypeORM to seed your system under t...
# i-need-help
g
I've tried to use TypeORM to reset my website database in the beforeeach hook without any success. Here's the exact error:
Copy code
TypeError: The following error originated from your test code, not from Cypress.

  > Cannot read properties of undefined (reading 'type')

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
  Here's how I create my connection:
Copy code
import {DataSource} from "typeorm";

export const AppDataSource = new DataSource({
  type: "postgres",
  host: "localhost",
  port: 5432,
  username: "postgres",
  password: "123",
  database: "test_typeorm",
  synchronize: true,
  logging: true,
})
b
you'll want to do your connection creation in a plugin file, not your spec file: https://docs.cypress.io/guides/tooling/plugins-guide#Real-World-Example here's an example of what we do for mongo: https://www.deploysentinel.com/blog/testing-mongo-apps-with-cypress