简体   繁体   中英

Is there way to spyOnProperty window.location.search using jasmine unit testing? because search is not configurable

Its throwing error: search is not configurable

it('should have search keyword', function () {
  spyOnProperty(window.location, 'search').and.returnValue("?q=jag");
  expect(window.location.search).toBe("?q=jag");
});
beforeEach(function () {
  window.history.pushState({}, '', "?q=jag");
})
it('should have search keyword', function () {
  expect(window.location.search).toBe("?q=jag");
  expect($('#decoder-search-bar-input').val()).toEqual('jag');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM