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

168
Views
Problem with mutation testing of expressjs app (Stryker mutator)

I have made an express app which is basically an RESTAPI and I have written tests in mocha for the application. Now I wanted to mutation test my app but I've run into a problem. My app listens to the port 8000 via the app.listen(8000) command of express and my tests test the app via the routes I've set up (for example localhost:8000/test). The problem I have when I try to mutation test with stryker is that every created mutant tries to access the port 8000 at the same time while testing and the mutants get killed because of "EADDRINUSE: adress already in use :::8000" resulting in 100% mutation score. I've already tried editing the test scipt from "mocha" to "mocha --exit" in package.json as well as closing the server after the last test finishes.

I think that the error could be easily reproducible by making a simple API with express, then writing tests that use the routes and trying to mutation test it with stryker. Is there any fix for this problem, any help is welcome!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is also an option in Stryker to have the concurrent tests (concurrency) that you could set to 1, to make the test engine only run 1 test at a time. This will be slow for the testing, but should work.

I am using NestJS for the framework of my API application with Express. From there, I can launch the application internally, using the testing module of NestJS. Do you have something similar?

In my case, I am able to launch the application in isolation in the beforeAll() methods, and then run tests.

beforeAll(async () => {
        const moduleFixture: TestingModule = await Test.createTestingModule({
            imports: [AppModule],
        }).compile();

        app = moduleFixture.createNestApplication();
        await app.init();
    });

    ...

    it('/bad (GET) address should be Not Found', async () => {
        const ResponseData$ = await request(app.getHttpServer()).get('/bad');

        expect(ResponseData$.body.statusCode).toBe(404);
        expect(ResponseData$.body.message).toBe('Cannot GET /bad');
    });

This is a simple test, but the app.getHttpServer() is the key that launches an internal call in my test, without needing the application running on the port, as the testing module has supported this.

This allows me to run all my tests with parallel execution, and also allow Stryker to run in parallel.

about 4 years ago · Juan Pablo Isaza Report
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!