如何更换Chai期望的Jext预期类型?

问题描述 投票:1回答:1

我想使用Chai作为断言库而不是Jest。我使用的是typescript,我想用Chai期望的类型替换全局Jest。

我尝试做类似的事情:

import chai from "chai";

type ChaiExpect = typeof chai.expect;

declare global {
  export const expect: ChaiExpect;
}

global.expect = chai.expect;

但打字稿抱怨是因为:

Cannot redeclare block-scoped variable 'expect'.ts(2451)
index.d.ts(39, 15): 'expect' was also declared here.

如何覆盖jest的index.d.ts中声明的类型?

typescript jestjs chai
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.