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

I want to set up once, and run many e2e tests in parallel against multiple copies of pg-mem #437

Open
andrecarlucci opened this issue Jan 6, 2025 · 1 comment

Comments

@andrecarlucci
Copy link

The idea is:

  1. create the DB: db = newDb();
  2. set up my schema using typeorm. (db.adapters.createTypeormDataSource()... syncrhonize()
  3. create a db backup. db.backup();
  4. put this all in a static class
  5. for each test requiring a DataSource, I would call a method from this static class creating a new DataSource pointing to the snapshot version of the database.

The problem is, db.backup() doesn't produce a new version of the database, it creates a snapshot point I have no access to.

I need something like:

var copyOfDb = db.backup();
newDataSource = await copyOfDb.adapters.createTypeormDataSource({...})

Any other way to achieve this?

@andrecarlucci
Copy link
Author

Hmm... I guess this is not possible, right?
If I got it right, Jest will run tests of different files in parallel each in its own process not sharing state between them.
This means my static context won't be shared and the best I will get is one instance of the DB per file anyway.
Would that be a correct assumption?

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

1 participant