Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda