How to use imported function inside page.evaluate in Puppeteer with Jest?

后端 未结 3 922
走了就别回头了
走了就别回头了 2021-02-20 02:30

I have a TypeScript project that uses Jest for unit tests and have just added Puppeteer to the mix with the intention to run some tests on the client. It works fine, unless I tr

3条回答
  •  感动是毒
    2021-02-20 03:06

    you can do like this before you invoke the evaluate function :

    await page.exposeFunction("applyHdpiOverrides",applyHdpiOverrides);
    await page.exposeFunction("createHdpiCanvas",createHdpiCanvas);
    

    and now your window will recognize these functions

提交回复
热议问题