'Jest not returning exit codes

I've trying to run tests for my Express + TS application through GitHub Actions

But even if my test fails, it seems Jest doesn't return a non-zero exit code so the GitHub Action workflow doesn't fails and it looks like the tests passed when they didn't

My workflow:

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
        
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16.5.0
 
      - name: Installing dependencies
        run: npm install

      - name: Running tests
        run: npm test

My test suite example:

const app: Application = Server.createServer();
const server: SuperTest<Test> = supertest(app);

const mainGetUrl: string = '/api/v1';
describe('Get server main endpoint', (): void => {
  it(`GET ${mainGetUrl}`, async () => {
    const res: Response = await server.get(mainGetUrl);
    expect(res.status).toEqual(200);
    expect(res.type).toEqual(expect.stringContaining('json'));
  });
});

I'm using "jest": "^27.1.4" and running the test with ./node_modules/.bin/jest --testTimeout=10000



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source