【问题标题】:Jest test, debug using dev tools玩笑测试,使用开发工具调试
【发布时间】:2018-04-04 11:22:24
【问题描述】:

我正在尝试使用 chrome 开发工具来调试我的测试。我有一个使用 jest 的简单测试设置

describe('App component renders the todo correctly', () => {
  it('renders correctly', () => {
    const rendered = renderer.create(
      <App />
    );
    expect(rendered.toJSON()).toMatchSnapshot();
  });
});

使用:"test": "node node_modules/jest/bin/jest.js --watch --silent",

我可以进入chrome://inspect/#devices并点击Open dedicated DevTools for Node

但是,在生成的dev tools 窗口中,我看不到任何要调试的内容。我期待一个可以设置断点和检查数据的过程。

如何在dev tools 中调试我的测试?

【问题讨论】:

  • 你使用什么命令来运行测试?

标签: react-native jestjs


【解决方案1】:

这可能会有所帮助:https://facebook.github.io/jest/docs/en/troubleshooting.html

本质上:在您的测试中添加debug; 语句。然后运行:

node debug --debug-brk node_modules/jest/bin/jest.js -i

【讨论】:

    【解决方案2】:
    node debug --debug-brk node_modules/jest/bin/jest.js -i
    

    (node:340) [DEP0068] DeprecationWarning: node debug 已弃用。请改用node inspect。 node --debug 和 node --debug-brk 无效。请改用node --inspect 和node --inspect-brk。

    使用这个

    node --inspect-brk node_modules/jest/bin/jest.js --runInBand
    

    【讨论】:

      猜你喜欢
      • 2020-08-16
      • 2018-04-05
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 2020-02-06
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多