0

I'm using Node and the node-postgres package and I would like to perform some unit tests using jest and supertest without saving to the actual database.

When using sequelize it is possible to configure the storage in memory, like so:

const sequelize = new Sequelize({
  ...
  storage: ":memory:"
});

I know it is possible to set the dialect to Postgres in sequelize, but I was wondering how would one go about to set the in memory storage using node-postgres. Is that possible?

Thanks

Eulavo
  • 39
  • 4

1 Answers1

0

I think in sequelize that ":memory:" storage would be available only for sqlite like in memory databases. It isn't possible to run postgresql in memory so you can't connect to in memory postgres from node-postgres/any client.

You can refer this answer for more details (Using in-memory PostgreSQL)

Shankar
  • 202
  • 5
  • Thank you. Would it be considered a bad practice to create a local database , separated from the actual database, just to run tests? – Eulavo May 03 '22 at 15:07
  • That's the way to do it I think. You can have different test database for running tests. – Shankar May 03 '22 at 15:13