Skip to content

Changing url does not work with Jest #1700

@mockdeep

Description

@mockdeep

I'm trying to change the window url in my Jest specs and it throws an error. Not sure if this is an issue with the way that Jest has configured jsdom, or a problem with jsdom. A small example:

import jsdom from 'jsdom';

it('works', () => {
  jsdom.changeURL(window, 'https://example.com?foo=butts')
});

I run it like:

$ jest --config config/jest.json spec/js/my_test.js

And get an error:

    TypeError: Cannot set property '_URL' of undefined
      
      at Object.<anonymous>.exports.changeURL (node_modules/jsdom/lib/jsdom.js:64:12)
      at Object.<anonymous> (spec/js/my_spec.js:6:45)

Not really much in the way of custom configuration on our part when it comes to Jest. Using jsdom@9.9.1 and jest@17.0.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions