【问题标题】:Using Jest's todo feature使用 Jest 的 todo 功能
【发布时间】:2019-07-14 01:29:15
【问题描述】:

release notes for Jest 24 突出显示了我想使用的一个新功能:test.todo。但是,我终生无法使用它。

例如,我想在我的 subscriptions.test.ts 文件中勾画出测试,所以我创建了以下内容:

describe('Subscription Tests', () => {
    test.todo('... a name');
});

TypeScript 编译器随即在todo 下方显示一条红线,表示Property 'todo' does not exist on type 'It'.

我确定我遗漏了一些明显的东西,但此时我已经碰壁了。有人可以帮忙吗?

【问题讨论】:

标签: javascript typescript jestjs ts-jest


【解决方案1】:

我有一阵子觉得自己很笨,因为在添加 todo() 后我的测试失败了。我应该更彻底地阅读文档。这是我有问题的代码:

test("should show progress indicator when authorizing", () => {
  test.todo("should show progress indicator when authorizing")
})

但它需要像下面这样。使用todo时传递回调,不允许在回调中嵌套test()

test.todo("should show progress indicator when authorizing")

【讨论】:

    【解决方案2】:

    感谢@jonrsharpe 的评论,我运行了yarn upgrade @types/jest --latest,这解决了我的问题。呃——只见树木不见森林!

    【讨论】:

    • npm i @types/jest@latest --save-dev 对于 npm 用户 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-24
    • 2019-09-18
    • 1970-01-01
    • 1970-01-01
    • 2018-02-24
    • 2020-08-29
    • 1970-01-01
    相关资源
    最近更新 更多