I have several integration tests,
when I run the tests together - one test fail (the second test of search the word "exemple"),
but if I run them individually each one - they work (all tests pass individually)
if I put skip to one test (No matter which test) the tests work
My code is:
const supertest = require('supertest');
const app = require('../../app.js');
const api = supertest(app);
// data of the "example" word
const resultOfWordExample = {...};
describe('search word test', () => {
test('of search the word "example" -> status: 200, body: { Items: [...example] }', async () => {
const res = await api
.get('/example')
.expect(200)
.expect('Content-Type', /application\/json/);
expect(res.body).toEqual(resultOfWordExample);
}, 10000);
test('of search the word "exemple" -> status: 404, message: "no result for this word"', async () => {
const res = await api
.get('/exemple')
.expect(404)
.expect('Content-Type', /application\/json/);
expect(res.body.error).toEqual('no result for this word');
}, 10000);
test('of search the word "example123" -> status: 400, message: "not word in English"', async () => {
const res = await api
.get('/example123')
.expect(400)
.expect('Content-Type', /application\/json/);
expect(res.body.error).toEqual('not word in English');
}, 10000);
});
afterAll(() => {
app.killServer();
});
Does anyone know why this works like this?