From 3a4601bbe4692c540ad8513428085763944abae4 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Tue, 8 Jun 2021 16:02:55 +0100 Subject: [PATCH] Set window location for individual test This is less surprising and means we don't end up in a situation where a future test needs to change the global config to something else. --- tests/javascripts/authenticateSecurityKey.test.js | 3 +++ tests/javascripts/jest.config.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/javascripts/authenticateSecurityKey.test.js b/tests/javascripts/authenticateSecurityKey.test.js index c2e778334..110314325 100644 --- a/tests/javascripts/authenticateSecurityKey.test.js +++ b/tests/javascripts/authenticateSecurityKey.test.js @@ -99,6 +99,9 @@ describe('Authenticate with security key', () => { }); test('authenticates and passes a redirect url through to the authenticate admin endpoint', (done) => { + // https://github.com/facebook/jest/issues/890#issuecomment-415202799 + window.history.pushState({}, 'Test Title', '/?next=%2Ffoo%3Fbar%3Dbaz'); + jest.spyOn(window, 'fetch') .mockImplementationOnce((_url) => { // initial fetch of options from the server diff --git a/tests/javascripts/jest.config.js b/tests/javascripts/jest.config.js index f686f6b69..881bcf89e 100644 --- a/tests/javascripts/jest.config.js +++ b/tests/javascripts/jest.config.js @@ -1,4 +1,4 @@ module.exports = { setupFiles: ['./support/setup.js'], - testURL: 'https://www.notifications.service.gov.uk/?next=%2Ffoo%3Fbar%3Dbaz' + testURL: 'https://www.notifications.service.gov.uk', }