简体   繁体   English

开玩笑等待不工作/返回任何测试被冻结

[英]Jest await not working/returning anything test is frozen

I am trying to use await in my test and when I run the test runner the test becomes stuck and no test result is returned.我正在尝试在我的测试中使用 await,当我运行测试运行程序时,测试卡住并且没有返回测试结果。 Here is my code这是我的代码

describe("retrieveCandidate", () => {
  describe("when settings are found", () => {
    beforeEach(() => {
      configurationApi = new ConfigurationApi(BaseUrl);
    });

    afterEach(() => {
      configurationApi = undefined;
    });
    it("should return set of configuration values", () => {
       const configurationValueSet: IConfigurationValueSet | undefined =
         await configurationApi?.retrieveCandidate(controlConfigurationValueSet.specializationKey);
      expect(true).toEqual(true);
    });
  });

So in my testsetup file I had所以在我的测试设置文件中

jest.useFakeTimers();

This caused my async functions to never return anything and caused my test to be in a frozen state这导致我的异步函数永远不会返回任何东西,并导致我的测试处于冻结状态 state

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM