Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URLSearchParams is not defined error when running tests with jest

How can I use URLSearchParams when running tests with Jest ?

When I do so I get

ReferenceError: URLSearchParams is not defined

like image 859
Lev Avatar asked Nov 27 '22 01:11

Lev


1 Answers

You just need to upgrade your version of react-scripts which uses the newest version of Jest that contains the ability to use URLSearchParams.

You can read more about it here: https://facebook.github.io/jest/blog/2017/12/18/jest-22.html#good-bye-node-4-welcome-jsdom-11.

like image 142
Luke Schmidt Avatar answered Nov 29 '22 04:11

Luke Schmidt