2

I need to capture the console error durring my Jest testing with puppeteer . Is any way do that ? Some code like this:

browser=await puppeteer.launch({headless:false,defaultViewport:{width:1920,height:1048}, args: ["--ash-host-window-bounds=1920x1080", "--window-size=1920,1048", "--window-position=0,0"]});
page =await browser.newPage();
await page.goto('http://localhost:4200/#/utilization');
//TODO : Keep an eye on console error.
test("测试浏览器是否有console error",
   page.on('pageerror',(mes)=>{
    expect(mes).toBe(null);
   });
   page.on('error',mes=>{
     expect(mes).toBe(null);
   })
 });
skyboyer
  • 22,209
  • 7
  • 57
  • 64
  • Possible duplicate of [Communicating between the main and renderer function in Puppeteer](https://stackoverflow.com/questions/52684640/communicating-between-the-main-and-renderer-function-in-puppeteer) – Md. Abu Taher Oct 10 '18 at 01:58

0 Answers0