Skip to content

TypeError: Cannot read property 'parentNode' of undefined #20

@dclowd9901

Description

@dclowd9901

airbnb-browser-shims version: ^2.1.0
Jest Version: ^21.2.1

This seems to be an issue with browser shims' compatibility with jsdom. A simple reconstruction of this issue would be to create a test file:

/* testfile.test.jsx */

/**
 * @jest-environment jsdom
 */

import 'airbnb-browser-shims';

describe('any test', () => {
  it('should do something', () => {
    console.log('it will fail before tests are run');
  });
});

This throws an error:

  ● Test suite failed to run

    TypeError: Cannot read property 'parentNode' of undefined
      
      at node_modules/matchmedia-polyfill/matchMedia.js:18:15
      at Object.<anonymous> (node_modules/matchmedia-polyfill/matchMedia.js:46:2)
      at Object.<anonymous> (node_modules/airbnb-browser-shims/browser-only.js:27:3)
      at Object.<anonymous> (node_modules/airbnb-browser-shims/index.js:7:1)
      at Object.<anonymous> (tests/DirectionProvider_test.jsx:14:1)
      at next (native)
      at next (native)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions