小编Flo*_*Kuc的帖子

Jest --覆盖测试错误:“渲染没有返回任何内容。”

当我运行纱线测试或纱线测试[文件名]时,我的所有组件都通过了测试。但是,当我使用 --coverage 标志运行测试时,出现以下错误,指向我创建的自定义渲染函数的包装器。自定义渲染函数或多或少是从react-testing-library文档中复制/粘贴的:https://testing-library.com/docs/react-testing-library/setup

到目前为止,我尝试过的以下命令均无效:yarn test --coverage、yarn test --coverage --watchAll=false、yarn test --collectCoverage、npm run test --coverage、npm run test --coverage --全部观看=假

错误:

Error: Uncaught [Error: Wrapper(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.]

  82 |              );
  83 |      };
> 84 |      return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
     |             ^
  85 | };
  86 | 
  87 | const render = (ui: ReactElement, { store = createStore(appReducer, initialState as AppApiStore), …
Run Code Online (Sandbox Code Playgroud)

reactjs test-coverage jestjs react-testing-library

6
推荐指数
0
解决办法
380
查看次数