Skip to content

Commit 7c7ea59

Browse files
committed
correct the customApiIntercept loading case
`req.reply()` was not returning an empty response, it was returning the actual response from the server. this led to the "loading" state being present momentarily before the actual response was returned. we are now forcing the loading state to remain, as the mock intends.
1 parent 4f1f813 commit 7c7ea59

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cypress/support/commands.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//
2424
// -- This will overwrite an existing command --
2525
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
26+
2627
import { scientistApiBaseURL } from './e2e'
2728

2829
// add a command to login that uses a session, so the user will remain logged in throughout the test file vs. needing to log in before each example.
@@ -44,10 +45,10 @@ Cypress.Commands.add('login', (username, password) => {
4445
Cypress.Commands.add('customApiIntercept', ({
4546
action, alias, data, defaultFixture, emptyFixture, error, errorCaseStatusCode, loading, requestURL
4647
}) => {
47-
cy.intercept(action, scientistApiBaseURL + requestURL, (req) => {
48+
cy.intercept(action, `${scientistApiBaseURL}${requestURL}`, (req) => {
4849
switch (true) {
4950
// reply with an empty response: both data and error will be undefined.
50-
case loading: req.reply()
51+
case loading: req.reply({})
5152
break
5253

5354
// error will be defined
@@ -66,4 +67,4 @@ Cypress.Commands.add('customApiIntercept', ({
6667
break
6768
}
6869
}).as(alias || 'customIntercept')
69-
})
70+
})

0 commit comments

Comments
 (0)