使用 Jest 的待办事项功能

Using Jest's todo feature

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'.

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

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

我有一阵子觉得很蠢,因为我的测试在添加 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")