Current behavior
I posted this problem on gitter and another user (@genughaben_gitlab) confirmed he also has this problem.
I want to stub my local REST API to test my front end in insolation. When the REST API is turned on, everything works as expected - the XHR are stubbed. When my REST API is turned off, the XHR fail and are not stubbed.
For example, here's what happens when my API is not started:



And here's what happens when I simply turn on my API and re-run the tests:

Desired behavior
My server should not be started for XHR stubs to work
Test code to reproduce
Unable to provide a repro, but here is test code for the test shown in the screenshot
describe('Project page', () => {
beforeEach(() => {
helper.login(1);
});
describe('when the play button is clicked', () => {
describe('when the stop button is clicked', () => {
it.only('should stop the project', () => {
defaultIntercepts();
cy.visit('https://localhost:4200/projects/1');
cy.get('#play-button').click();
cy.get('#stop-button').click();
const playheadLeftPosObj = { pos: 0 };
setInitialPlayheadLeftPos(playheadLeftPosObj);
cy.get('#playhead').should(($el: any) => {
expect($el[0].getBoundingClientRect().left).to.equal(
playheadLeftPosObj.pos
);
});
});
});
});
});
function defaultIntercepts() {
cy.intercept('GET', '/users/1', {
id: 1
});
cy.intercept(
'GET',
'/projects/1?used-space-wavs-and-videos',
createProjectFixtures({})
);
cy.intercept('GET', '/projects/1/tracks', []);
cy.intercept('GET', '/projects/1/files?is-consolidation', []);
}
Versions
This issue did not occur with cy.route.
Cypress version: 6.1
Chrome version: Version 87.0.4280.67 (Official Build) (x86_64)
OS version: mac os 10.15.7
Current behavior
I posted this problem on gitter and another user (@genughaben_gitlab) confirmed he also has this problem.
I want to stub my local REST API to test my front end in insolation. When the REST API is turned on, everything works as expected - the XHR are stubbed. When my REST API is turned off, the XHR fail and are not stubbed.
For example, here's what happens when my API is not started:
And here's what happens when I simply turn on my API and re-run the tests:
Desired behavior
My server should not be started for XHR stubs to work
Test code to reproduce
Unable to provide a repro, but here is test code for the test shown in the screenshot
Versions
This issue did not occur with
cy.route.Cypress version: 6.1
Chrome version: Version 87.0.4280.67 (Official Build) (x86_64)
OS version: mac os 10.15.7