How can I configure the jsdom instance used by jest?

前端 未结 4 1255
清歌不尽
清歌不尽 2021-02-13 23:07

I\'ve come up against this issue Invalid URL is thrown when requiring systemjs in jest test cases

One of the last comments suggests

\"manipulate the jsdom instan

4条回答
  •  半阙折子戏
    2021-02-13 23:49

    I just went down this road and found out that as of Jest 21.2.1, the official way is to fork your own JSDom environment.

    This is a bit painful to set up but allows in-depth customization.

    References:

    • https://github.com/facebook/jest/issues/2484#issuecomment-270174381
    • https://github.com/facebook/jest/issues/2460#issuecomment-324630534

    Sample environment: https://github.com/mes/jest-environment-jsdom-external-scripts

提交回复
热议问题