无法在节点devTools下的chrome中使用Jest调试测试用例 [英] Unable to debug test case using Jest in chrome under node devTools

查看:86
本文介绍了无法在节点devTools下的chrome中使用Jest调试测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Jest. 用于在测试用例文件下进行调试;

  describe("Filter function", () => {
  test("it should filter by a search", () => {
    const input = [
      { id: 1, url: "https://www.google.com" },
      { id: 2, url: "https://www.yahoo.com" },
      { id: 3, url: "https://www.gmail.com" }
    ];

    const output = [{ id: 3, url: "https://www.gmail.com" }];
    debugger;
    expect(filterByTerm(input, "gmail")).toEqual(output);
    debugger;
    expect(filterByTerm(input, "GMAIL")).toEqual(output);
  });

 
});

在Project目录下-运行此命令

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

运行此命令后说 节点--inspect-brk node_modules/jest/bin/jest.js --runInBand 侦听ws://127.0.0.1:9229/ab651461-dfe8-4528-8a07-484a4be5db7b的调试器 如需帮助,请参阅: https://nodejs.org/en/docs/inspector

在此打开的chrome://inspect之后,单击Node的打开的专用devtools 在这里,它打开了一个窗口,我在其中添加了src文件夹并打开了测试文件,但是调试没有来. 请在同一问题上提供帮助

但是,在出现的开发工具窗口中,我看不到要调试的任何东西.我期待有一个可以设置断点和检查数据的过程.

解决方案

运行此命令;

node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand
Debugger listening on ws://127.0.0.1:9229/6a0bb29e-eca2-4a25-b894-a5e803339ec9
For help, see: https://nodejs.org/en/docs/inspector

之后,在chrome中输入该网址;

devtools://devtools/bundled/inspector.html?experiments = true& v8only = true& ws = 127.0.0.1:9229/6a0bb29e-eca2-4a25-b894-a5e803339ec9

并再次恢复右侧的按钮.再次按F8键,等待一段时间,调试开始.在测试文件中的调试器上;被写

再次感谢您!

I just started using Jest. For debugging under testcase file;

  describe("Filter function", () => {
  test("it should filter by a search", () => {
    const input = [
      { id: 1, url: "https://www.google.com" },
      { id: 2, url: "https://www.yahoo.com" },
      { id: 3, url: "https://www.gmail.com" }
    ];

    const output = [{ id: 3, url: "https://www.gmail.com" }];
    debugger;
    expect(filterByTerm(input, "gmail")).toEqual(output);
    debugger;
    expect(filterByTerm(input, "GMAIL")).toEqual(output);
  });

 
});

under Project directory - run this command

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

After running this command says node --inspect-brk node_modules/jest/bin/jest.js --runInBand Debugger listening on ws://127.0.0.1:9229/ab651461-dfe8-4528-8a07-484a4be5db7b For help, see: https://nodejs.org/en/docs/inspector

after this opened chrome://inspect under it clicked on open dedicated devtools for Node here, It opened window where I added src folder for same and opened test file but debugging didnt came. Help please on same issue

However, in the resulting dev tools window, I can't see anything to debug. I am expecting a process where I can set breakpoints and inspect data.

解决方案

Run this command;

node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand
Debugger listening on ws://127.0.0.1:9229/6a0bb29e-eca2-4a25-b894-a5e803339ec9
For help, see: https://nodejs.org/en/docs/inspector

After this enter this url in chrome;

devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/6a0bb29e-eca2-4a25-b894-a5e803339ec9

and Resume the button on right hand side again Press again F8 wait for some time, Debugging started Like charm..! on your test file where debugger; is written

Thank you again !

这篇关于无法在节点devTools下的chrome中使用Jest调试测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆