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

后端 未结 3 904
走了就别回头了
走了就别回头了 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 02:41

    The solution suggested by Meni Roytenburd is correct. If you don't like the fact that every function needs to be exposed to the browser separately, the only idea that comes to mind is transpiling your project to a single JavaScript file first and then injecting it as a

提交回复
热议问题