This repository was archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Error with enzyme mount function #9
Copy link
Copy link
Open
Description
jest-environment-node-debug-fixed
is generating this error on all tests:
TypeError: ModuleMocker is not a constructor
jest-environment-node-debug work a little better in my case but fail on managing global vars.
simple tests such as
import React from 'react'
import { mount, shallow } from 'enzyme'
import GenericTemplate from '.'
const wrap = (props = {}) => shallow(
<GenericTemplate {...props}>test</GenericTemplate>
)
it('mounts', () => {
mount(<GenericTemplate>test</GenericTemplate>)
})
it('renders children when passed in', () => {
const wrapper = wrap()
expect(wrapper.contains('test')).toBe(true)
})
Will fail with the output
It looks like you called `mount()` without a global document being loaded.
Also trying to mock window like that:
window.gapi = {
load: () => {},
auth2: {
init: () => auth2,
getAuthInstance: () => auth2,
},
}
will fail with the output
ReferenceError: window is not defined
Without using the debugger and --env jest-environment-node-debug all my tests passes without errors.
Metadata
Metadata
Assignees
Labels
No labels