Current behavior:
I've watched this video for best practices on Cypress https://www.youtube.com/watch?v=5XQOK0v_YRE
The video mentioned along was to create a custom command for "login" / "signup" . And so I wonder how can I mock or use fixtures for my custom commands that uses cy.request inside?
Desired behavior:
Can be mocked by fixtures
Test code to reproduce
export const signup = () => {
Cypress.Commands.add('signup', () => {
cy.request({
url: 'localhost:8000/api/signup',
method: 'POST',
body: {
email: TestingFactory.fake.email(),
password: TestingFactory.fake.hash({
length: 15,
}),
firstName: TestingFactory.fake.first(),
lastName: TestingFactory.fake.last(),
},,
}).then(({
body: {
session: {
token: ownerToken,
},
user: {
roleId: ownerID,
},
},
}) => {
cy.window().its('store').invoke('dispatch', {
type: 'sign_up_success',
payload: {
ownerID,
ownerToken,
},
});
});
});
};
Versions
4.0
macOS
Google Chrome
Current behavior:
I've watched this video for best practices on Cypress https://www.youtube.com/watch?v=5XQOK0v_YRE
The video mentioned along was to create a custom command for "login" / "signup" . And so I wonder how can I mock or use fixtures for my custom commands that uses
cy.requestinside?Desired behavior:
Can be mocked by fixtures
Test code to reproduce
Versions
4.0
macOS
Google Chrome