Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.

Error with enzyme mount function  #9

@rolele

Description

@rolele

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions