`window` is not being exposed to Jest

后端 未结 6 1439
挽巷
挽巷 2021-02-12 16:50

I have a test that imports a component that in turn imports a helper file that uses the window object to pull out a query string parameter. I get the following erro

6条回答
  •  野的像风
    2021-02-12 17:15

    Not sure but i think you could do it with jest.fn()

    global.window = jest.fn(() => {
      location: { ... }
    })
    

    maybe even as window = jest.fn(...)

提交回复
热议问题