Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
Share compiled module reference across test cases

I have got a standard unit test for nestjs application

// test.spec.ts

describe('test case', () => {

  beforeAll(async () => {
    module = await createTestingModule();
  });
});

// testSetup.ts

export async function createTestingModule() {
  return Test.createTestingModule({
      imports: [AppModule],
  }).compile();
}

But Test.createTestingModule is called in every test case which takes some time. Can I somehow save the reference to the compiled module and reuse it in other tests?

  • first test runs createTestingModule, compiles the module and save the reference
  • next tests runs createTestingModule, but instead of compiling it they will use reference

Script I use to run tests jest --setupFiles dotenv/config --coverage --runInBand --detectOpenHandles --forceExit --logHeapUsage

I was trying to store it in process object but i think its not possible this way.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!