https://cypress.io logo
Join Discord
Powered by
# e2e-testing
  • a

    acceptable-hamburger-48790

    09/30/2022, 12:35 PM
    so when you need it then you again need to call it like cy.get('"@someName").then((data) => {//do something here})
  • g

    gentle-accountant-4760

    09/30/2022, 12:37 PM
    and how do I call the itemLists as I need to pass a requestUrl then? 🤔 how would cy.get("@something") know what I want to pass?
  • a

    acceptable-hamburger-48790

    09/30/2022, 12:40 PM
    class BarryApi{ static itemLists(requestUrl: string): any { let itemList; const signatureHeaders = [ { name: 'override', value: 'hello_world' }, ]; cy.task('Signature', { pathToSign, headers: signatureHeaders }).then((signature) => { cy.request({ url: requestUrl, method: 'GET', headers: { 'signature': signature, }, failOnStatusCode: false, log: true, }) .then((response) => { cy.wrap(JSON.stringify(response.body)).as("itemList"); }); }); } } export default BarryApi;
  • g

    gentle-accountant-4760

    09/30/2022, 12:40 PM
    Right😁
  • a

    acceptable-hamburger-48790

    09/30/2022, 12:40 PM
    then in the test you will use cy.get("@itemList").then((itemList) => {// continue what you want here})
  • g

    gentle-accountant-4760

    09/30/2022, 12:42 PM
    But it it still incorrect because you are not passing any URL to itemLists e.g.
    Copy code
    ts
    BarryApi.itemLists('https://barrythrill.com');
    how else will it know which url you want to do a request too?
  • a

    acceptable-hamburger-48790

    09/30/2022, 12:43 PM
    You are not changing the original class, it will be as it is where you pass the url
  • a

    acceptable-hamburger-48790

    09/30/2022, 12:44 PM
    all we are doing is wrapping the itemList fetched in then block and saving it as alias
  • g

    gentle-accountant-4760

    09/30/2022, 12:45 PM
    so you mean I need to do something like this:
    Copy code
    ts
    BarryApi.itemLists('https://barrythrill.com');
    cy.get("@itemList").then((itemList) => {// continue what you want here};
  • a

    acceptable-hamburger-48790

    09/30/2022, 12:45 PM
    yeah
  • g

    gentle-accountant-4760

    09/30/2022, 12:45 PM
    Ahhh ok will give that a try 😁
  • g

    gray-kilobyte-89541

    09/30/2022, 3:05 PM
    you should run
    wait-on
    before starting Cypress. And yes, look at the docs, there are lots of options for timeouts
  • g

    gray-kilobyte-89541

    09/30/2022, 3:06 PM
    this is exactly why I don't recommend using page objects, since you have to remember "did this already set internal state? did I return chainable instance so people do .then?"
  • m

    mysterious-belgium-25713

    09/30/2022, 3:31 PM
    I think if you know a certain page is slow you can also add a for that command that runs slow.
    Copy code
    js
    cy.visit('/index.html', { timeout: 30000 })
  • a

    acceptable-tailor-43291

    09/30/2022, 3:37 PM
    With fixed timeout, sometimes app takes more than that timeout and tests break. Should I add a maximum time limit for that page to load?
  • n

    nutritious-megabyte-64190

    09/30/2022, 3:40 PM
    cypress-auditexamplescra-authenticated...
  • a

    average-tomato-41838

    09/30/2022, 4:24 PM
    Hello , does anyone has faced this problem, I have a class with all my elements ( clases , locators ets) and actions (like click , find etc..)
    Copy code
    import { BasePage } from './basePage';
    
    export class xdInteriorInspection extends BasePage {
        // Element getters
        confirmFuel(): Cypress.Chainable<JQuery<HTMLElement>> {
            return cy.contains('.jss2', "Confirm");
        }
    
        continueButton(): Cypress.Chainable<JQuery<HTMLElement>> {
            return cy.get('.jss26 > .jss16 > .MuiButtonBase-root');
        }
    
        // Interior damage confirmation
        clickConfirmFuel() {
            this.confirmFuel().click({ force: true });
        }
    
        clickContinueButton() {
            this.continueButton().click({ force: true });
        }
    }
    when I try to execute a click , it does nothing , I call it like this: interiorInspection.confirmFuel();
  • a

    average-tomato-41838

    09/30/2022, 4:26 PM
    the actions are not performed or recorded on the snapshots
  • r

    rough-night-37887

    09/30/2022, 4:29 PM
    You are not changing the original class
  • r

    rough-night-37887

    09/30/2022, 5:19 PM
    Can someone help me understand why this wait does not work??
  • p

    powerful-gigabyte-69168

    09/30/2022, 6:13 PM
    Does cypress try to add a
    stack
    property to uncaught application errors? I am getting a type error
    TypeError: Cannot create property 'stack' on string 'Forbidden'
    that I suspect is coming from cypress attempting to update an error to have a
    stack
    attribute, when it's actually receiving a string. Does that seem plausible?
  • m

    mysterious-belgium-25713

    09/30/2022, 6:28 PM
    You can combine both techniques. First use the wait on to fully see if the server is responding and have a extra timeout for the page.
  • g

    gray-kilobyte-89541

    09/30/2022, 6:45 PM
    what is
    resolve
    thing there? I think you are using
    cy.intercept
    incorrectly
  • r

    rough-night-37887

    09/30/2022, 7:32 PM
    I am trying to do a wait on a request I am making, but I am unable to, I need that get response to be used in another request
  • g

    gray-kilobyte-89541

    09/30/2022, 8:26 PM
    cy.wait(...).its('response.body').then(res => ...)
    ? No? You could benefit from this course https://cypress.tips/courses/network-testing
  • g

    great-answer-57072

    10/01/2022, 1:18 AM
    Hi, I am trying to bring tests results to the cypress dashboard, but I have no idea why "undefined" thing happened. There's no problem when I run tests locally.
  • g

    great-answer-57072

    10/01/2022, 1:33 AM
    https://github.com/cypress-io/cypress/issues/7959 I think this is the same issue as GitHub issue.
  • g

    great-answer-57072

    10/01/2022, 1:34 AM
    Someone did PR in 2020, but maybe it's different behavior and settings
  • g

    great-answer-57072

    10/01/2022, 1:35 AM
    Should I open an GitHub issue or leave the message here?
  • r

    red-toddler-79937

    10/01/2022, 1:59 PM
    HTML
    Copy code
    html
    <mat-tab data-testid="new-tab-title">
    ```Does anyone know how I can fix this?
    
    E2E:
    ```ts
    describe('Restaurant orders overview', () => {
        beforeEach(() => {
            initializeDesktop();
            login();
            addNewRestaurantProduct(1)
            cy.visitPage('orders', 'restaurant-orders');
        });
    
        describe('New orders', () => {
            it('Should have at least one new order', () => {
                cy.findAllByTestId('new-tab-title');
            });
        });
    Does anyone know why it can't find the Cypress test id?
1...111112113...192Latest