Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dclowd9901 opened this issue Jun 12, 2018 · 2 comments
Closed

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

dclowd9901 opened this issue Jun 12, 2018 · 2 comments

Comments

@dclowd9901
Copy link

dclowd9901 commented Jun 12, 2018

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)
@ljharb
Copy link
Contributor

ljharb commented Jun 12, 2018

This seems fixed by paulirish/matchMedia.js#82 / paulirish/matchMedia.js#76

@ljharb
Copy link
Contributor

ljharb commented Jun 13, 2018

ok now v0.3.1 is published, and i've confirmed that fixes the issue with jest.

2e55420 forces the update, but the semver range already includes it, so this should be automatic with a reinstall.

@ljharb ljharb closed this as completed Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants