为什么 supertest 在我的本地计算机上工作,但在 bitbucket 管道中不起作用?

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

提问人:Davy Vos 提问时间:10/30/2023 最后编辑:OBrien EvanceDavy Vos 更新时间:11/1/2023 访问量:21

问:

在 bitbucket 管道中运行 supertest 时,我遇到以下问题:

错误:超时超过 10000 毫秒。对于异步测试和钩子,请确保 “done()”被调用;如果返回 Promise,请确保它已解析。 (/opt/atlassian/pipelines/agent/build/dist/test/controller.spec.js)

以下是测试命令:

“test”: “npx tsc & & mocha ./dist/test/* --超时 10000”, “coverage”: “纽约市 npm 运行测试”,

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);
      });
      
});

我使用 mocha 进行 supertest 测试。 在本地,测试运行良好,但在 Bitbucket 管道中,它会出错并继续运行。我做错了什么?

我尝试不使用异步等待,而是手动调用完成,但这也没有用。

TypeScript Express Mocha.js SuperTest NYC

评论


答: 暂无答案