Ali Tourani
Ali Tourani

Reputation: 1247

Error while running integration test with Prisma Migrate

For migration management, I've decided to use Prisma Migrate instead of node-pg-migrate (PostgreSQL). I followed the instructions in this link and everything works fine. However, the main challenge is that my integration tests fail when trying to run migrations on the test database (not the develop database). How can I override the configurations of my test database?

In node-pg-migrate I could simply provide configurations before running the integration test:

import migrationRunner from 'node-pg-migrate';

// --- Integration test setup:
beforeAll(async () => {
  await migrationRunner({
    migrationsTable: dbConfig['migrations-table'],
    dir: dbConfig['migrations-dir'],
    schema: dbConfig.schema,
    databaseUrl: databaseURL,
    // --- other configs
  });
}, config.get('test').timeout);

Upvotes: 0

Views: 439

Answers (1)

Ryan
Ryan

Reputation: 6327

You can override the entire connection string directly in your test setup as follows. Prisma reads the DB string from environment variables so overriding in the following manner will work fine.

Upvotes: 1

Related Questions