storybook 插件交互:Assert出现在步骤之外,看起来像是在步骤内部,

new9mtju  于 3个月前  发布在  其他
关注(0)|答案(1)|浏览(30)

描述bug

在使用 play 函数中的 step 构造并编写一个在步骤之外、但在 waitFor 内部的交互/Assert时,面板提供了错误的视觉效果。
以下看起来正确的代码(没有使用 waitFor):

export const SyncWaitFor = {
  play: async ({ canvasElement, step }) => {
    const canvas = within(canvasElement);
    await step('Callback play fn', Callback.play);
    await expect(await canvas.findByText('Completed!!')).toBeInTheDocument();
  },
};

这是它的样子(折叠了步骤):

而这里看起来是错的:

export const SyncWaitFor = {
  play: async ({ canvasElement, step }) => {
    const canvas = within(canvasElement);
    await step('Callback play fn', Callback.play);
    await waitFor(() => expect(canvas.getByText('Completed!!')).toBeInTheDocument());
  },
};

看起来也是这样,同样是折叠了步骤:

重现

在 monorepo 中运行沙箱示例
在这个故事中使用上面的代码

附加上下文

这是使用 @storybook/testing-library v0.14.0-next.0,它应该具有 waitFor 的正确仪器

相关问题