Why does supertest work on my local machine but not in a bitbucket pipeline?

55 views Asked by At

While running supertest in a bitbucket pipeline I get the following issue:

Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/opt/atlassian/pipelines/agent/build/dist/test/controller.spec.js)

These are the test commands:

"test": "npx tsc && mocha ./dist/test/* --timeout 10000", "coverage": "nyc npm run test",

describe('Controller tests', () => {

    const app: Express = express();
    app.use(express.json());
    app.use('', caseController);
    Container.set(CaseRepository, MockCaseRepository);
    Container.set('logger', new logger())

    it('should handle a valid request', async () => {
        return await request(app)
          .post('')
          .send(validPubSubMessage)
          .expect(200);
      });

      it('should handle a invalid base64 request', async () => {

        return await request(app)
          .post('')
          .send(invalidBase64PubSubMessage)
          .expect(400);
      });

      it('should handle a invalid json request', async () => {
    
        return await request(app)
          .post('')
          .send(InvalidJsonPubSubMessage)
          .expect(400);
      });

      it('should handle a missing data request', async () => {
    
        return await request(app)
          .post('')
          .send(missingDataPubSubMessage)
          .expect(400);
      });
      
});

I use mocha for testing with supertest. Locally the tests run fine but in the Bitbucket pipeline it errors and keeps running. What am I doing wrong?

I have tried to not use async await and instead call done manually but that didn't work either.

0

There are 0 answers