Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.route to match on request body for POST #3755

Closed
cookiescrumbs opened this issue Mar 20, 2019 · 7 comments
Closed

cy.route to match on request body for POST #3755

cookiescrumbs opened this issue Mar 20, 2019 · 7 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@cookiescrumbs
Copy link

cookiescrumbs commented Mar 20, 2019

Current behavior:

cy.fixture('teacher/my-library/skills').then((data) => {
    cy.server();
    cy.route({
        url: '/tag/search',
        method: 'POST',
        response: data
});

cy.fixture('teacher/my-library/level').then((data) => {
    cy.server();
    cy.route({
        url: '/tag/search',
        method: 'POST',
        response: data
});

Currently cy.route doesn't match the POST request body which means you can't stub requests that have the same url but a different request body.

Desired behavior:

cy.fixture('teacher/my-library/skills').then((data) => {
    cy.server();
    cy.route({
        url: '/tag/search',
        method: 'POST',
        response: data,
        body: {"filter":{"family":["skills"]}}
});

cy.fixture('teacher/my-library/level').then((data) => {
    cy.server();
    cy.route({
        url: '/tag/search',
        method: 'POST',
        response: data,
        body: {"filter":{"family":["Lesson Type"]}}
});
@SamShiSS
Copy link

Same issue here

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Mar 26, 2019

Duplicate of #3248 also - #3333

@jennifer-shehane jennifer-shehane marked this as a duplicate of #3333 Mar 26, 2019
@jennifer-shehane jennifer-shehane added the type: duplicate This issue or pull request already exists label Mar 26, 2019
@cookiescrumbs
Copy link
Author

cookiescrumbs commented Mar 26, 2019

@jennifer-shehane I'm not sure that those are the same as what I'm asking here.
If they are then what is the resolution? Do you have documentation that I could use to stub two post requests with the same url but different requests?

Please could you take another look at my example above and advise on how I might achieve the desired behaviour with the current tools available in cypress.

Thanks

@jennifer-shehane
Copy link
Member

@cookiescrumbs Right, sorry, this is different than I was thinking.

Some of this is slightly discussed in this issue #521 but ultimately the functionality that you want is covered in this issue: #387

There are likely some hacky workarounds, especially if you search our issues for graphql, but no way to officially do this through Cypress.

hossam-magdy added a commit to hossam-magdy/cypress that referenced this issue Feb 21, 2020
@jlgaustin
Copy link

I don't see this in 4.1? Am I missing something or when will this be available?

@cookiescrumbs
Copy link
Author

Is there an update on this issue?

@jennifer-shehane
Copy link
Member

This functionality has not been released. This is a duplicate issue. Please see #521 or #387 depending on your request.

@cypress-io cypress-io locked and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants