Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda