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

    quick-gpu-68223

    09/15/2021, 1:25 PM
    But the task should be run inside a test no ? Me i want to run only one time this command. But it should be apply before every test. It a seed db via docker.
  • i

    important-river-75795

    09/15/2021, 2:32 PM
    I would get all the values, then all the values from the elements , and create a boolean to use , if any of the strings differ make it return false and at the end of comparing just assert that boolean to be true/false
  • f

    fancy-airplane-60156

    09/16/2021, 10:31 AM
    Thanks for taking time to respond to that . That's something I could do. Not sure how it'll be reported in the test report. I'm also considering that aspect of it.
  • i

    important-river-75795

    09/16/2021, 10:48 AM
    @User If I recall correctly, you can do assertions and add a custom message at the end, so add the array of the elements that were not the same into the message and it should be good to go
  • f

    fancy-airplane-60156

    09/16/2021, 10:49 AM
    That would be great starting tip for me. Thank you so much !
  • f

    fancy-airplane-60156

    09/16/2021, 12:57 PM
    I found a way and made changes. All my verification are in a JS function in a separate file. I saved all the files and restarted Cypress and ran the test. It continues to run the old code instead of the updated. Not sure if there is a way to retsart cypress with clearing the cache.
  • g

    gray-kilobyte-89541

    09/16/2021, 2:26 PM
    I have some ideas, will probably write a blog post / make a video
  • f

    fancy-airplane-60156

    09/17/2021, 1:37 AM
    Thank you so much @User
  • j

    jolly-helicopter-87687

    09/21/2021, 1:18 PM
    Hi. I'm trying to get e2e & components tests working side by side in a new Vite/Vue3 app. Component tests seem to be working fine (sweet!) as per https://github.com/cypress-io/cypress-component-testing-examples However for e2e I'm stuck on
    TypeError: Failed to resolve module specifier "vue".
    when running a basic test like
    cy.visit('/')
    . Via
    cypress open
    I'm assuming there's some devserver config I might be missing. So far I've only got this in the plugins index:
    Copy code
    const path = require('path')
    const { startDevServer } = require('@cypress/vite-dev-server')
    
    module.exports = (on, config) => {
      on('dev-server:start', (options) => {
        return startDevServer({
          options,
          viteConfig: {
            configFile: path.resolve(__dirname, '../../vite.config.js')
          }
        })
      })
    
      return config
    }
    Thoughts/pointers?
  • b

    bulky-sundown-74498

    09/21/2021, 2:38 PM
    One thing that bit me hard a couple of times is that vite resolves it's own config file. So, if your config file is `vite.config.js`/`ts`, you should remove all the vite config and have:
    Copy code
    js
    const { startDevServer } = require('@cypress/vite-dev-server')
    
    module.exports = (on, config) => {
      on('dev-server:start', (options) => {
        return startDevServer({
          options
        })
      })
    
      return config
    }
  • j

    jolly-helicopter-87687

    09/21/2021, 3:56 PM
    @User thanks for the suggestion! I've tried it but things seem to stay the same. However, to simplify things, I just cloned the exmaple app https://github.com/cypress-io/cypress-component-testing-examples/tree/main/vite-vue and made 2 small changes: 1. Added
    /cypress/integrations/Basic.spec.js
    Copy code
    js
    describe('My First Test', () => {
      it('Does not do much!', () => {
        cy.visit('/')
        expect(true).to.equal(true)
      })
    })
    If you try to
    npx cypress open
    now and run
    Basic.spec
    you'll get a css loader error mentioning Webpack, oddly enough. So: 2. Commented out
    import '../../src/main.css'
    from
    /cypress/support/index.js
    which as I understand should only be needed for the components tests. If you run
    Basic.spec
    now you'll get the same error I'm having in my own app:
    TypeError: Failed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../".
  • b

    bulky-sundown-74498

    09/21/2021, 4:09 PM
    I will investigate after lunch (in a couple hours)
  • j

    jolly-helicopter-87687

    09/21/2021, 4:09 PM
    cheers! 🙂
  • t

    thankful-lunch-80439

    09/21/2021, 11:21 PM
    Hmm. I'm not too stoked with having to use
    cypress-real-events
    instead of something like
    trigger
    or
    invoke
    . Though it seems that it's an acceptable solution that a lot of developers are using. Is there something I'm not trying?
  • b

    broad-river-71789

    09/29/2021, 8:20 PM
    I have a request repeated twice in my test, the first time it works when i validate the xhr.response.statusCode, or xhr.response.body.isReferred. the second time when i use the same to validate, it fails. what could be the solution? sample response yielded is attached. im using cy.intercept
  • t

    thankful-lunch-80439

    09/29/2021, 8:41 PM
    You need the request to run twice?
  • b

    broad-river-71789

    09/30/2021, 12:25 AM
    in the application it happens twice. once when i create a data and second time when i edit and submit in the same spec
  • b

    broad-river-71789

    09/30/2021, 12:26 AM
    in the application it happens twice. once when i create a data and second time when i edit and submit in the same spec
  • t

    thankful-lunch-80439

    09/30/2021, 12:28 AM
    You can have two
    cy.intercept
    then. Sounds like
    cy.intercept("POST", /api).as("createThing")
    and
    cy.intercept("PATCH", /api/).as("editThing")
    I don't know if this is a best practice, though may resolve the issue here @User
  • b

    broad-river-71789

    09/30/2021, 12:29 AM
    Thank you. I will try this
  • t

    thankful-lunch-80439

    09/30/2021, 12:29 AM
    word, lmk how it goes
  • b

    broad-river-71789

    09/30/2021, 12:42 AM
    picking the previous alias only. tried with both PATCH and POST
  • t

    thankful-lunch-80439

    09/30/2021, 12:42 AM
    So it's the same endpoint with the same type of request? Is this a REST api?
  • b

    broad-river-71789

    09/30/2021, 12:43 AM
    yes same endopoint, same type of request, yes REST
  • t

    thankful-lunch-80439

    09/30/2021, 12:45 AM
    ah well of course that ain't gonna work 😂 Sorry idk if I can help from here. Feel free to DM me so we don't flood this thread
  • b

    broad-river-71789

    09/30/2021, 12:49 AM
    thank you
  • i

    important-river-75795

    09/30/2021, 9:51 AM
    @User intercept with an if statement checking whats in the body might work?
  • b

    broad-river-71789

    09/30/2021, 1:45 PM
    cy.wait("@rating", { timeout: 60000 }); cy.get("@rating").then((xhr: any) => { expect(xhr.statusCode).to.eq(200); const quotestatus = xhr.response.body.isReferred; cy.wrap(xhr.response.body.isReferred).as("quoteisrefBool"); });
  • b

    broad-river-71789

    09/30/2021, 1:46 PM
    I have the above piece of code, this works fine after the first request, the second time doesnt recognize statusCode and the other flag
  • t

    thankful-lunch-80439

    10/02/2021, 5:53 AM
    I think the first line may be consuming 1st request, and the cy.get the 2nd. So maybe it should be
    Copy code
    js
    cy.wait("@rating", { timeout: 60000 }).then((xhr: any) => {
      expect(xhr.statusCode).to.eq(200);
      const quotestatus = xhr.response.body.isReferred;
      cy.wrap(xhr.response.body.isReferred).as("quoteisrefBool");
    });
    a 60 second timeout is quite generous too 😅 Also, I could be wrong, though i think this may be clear for you too
    Copy code
    js
    cy.wait("@rating", { timeout: 60000 }).then({ response}) => {
      expect(response.statusCode).to.eq(200);
      cy.wrap(response.body.isReferred).as("quoteisrefBool");
    });
    • 1
    • 1
1...232425...192Latest