https://cypress.io logo
Join Discord
Powered by
# help
  • f

    flat-electrician-52949

    06/24/2021, 9:48 AM
    I know that I can add it to an
    it('shows a ticket number', () => {..
  • f

    flat-electrician-52949

    06/24/2021, 9:49 AM
    but I'm wondering if there is an option
  • b

    bulky-sundown-74498

    06/24/2021, 2:02 PM
    We do exactly that in the cypress codebase 😉 very useful
  • b

    bulky-sundown-74498

    06/24/2021, 2:43 PM
    Could it be possible that you have an orphan process somewhere blocking your bash? I would try restarting and trying again if you can. We use a package called
    execa
    to run the exec command. It is a wrapper for the
    const { spawn } = require('child_process');
  • b

    bulky-sundown-74498

    06/24/2021, 2:45 PM
    you can find teh code for the exec command (on the backend) here https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/exec.js
  • b

    bulky-sundown-74498

    06/24/2021, 2:50 PM
    Kind of: To do that, you have to create a custom command in which you use the contains but use the option
    log: false
    and provide your own logs using
    cy.log
    . At least that is how I would do it.
  • r

    ripe-daybreak-97926

    06/25/2021, 5:16 AM
    Hi, I have an issue with cypress execution via CI / CD. I have tried to contact someone in cypress but did not have luck. Please provide me a solution to the following issue. https://github.com/cypress-io/cypress/issues/3310#issuecomment-861415946 . Cypress Log - https://drive.google.com/file/d/1wsa_89GsQv4OJDUwEMZYeTTj3CMZ3S-R/view?usp=sharing
  • w

    wooden-parrot-13301

    06/25/2021, 10:46 AM
    hi guys i'm having a bad time running cypress - im using the vue cli plugin when i run
    vue-cli-service test:e2e
    the baseUrl is overridden from CLI. How do i prevent it
  • n

    nutritious-kilobyte-6207

    06/25/2021, 7:34 PM
    Hello, hoping for some advice on what might be going awry in my code coverage flow, or pointers for troubleshooting further. I've instrumented the source code using
    nyc instrument
    , and the coverage is getting picked up and reported for the
    .js
    files just fine. Now the issue is that I have
    .js.map
    files pointing back to the pre-compile CoffeeScript source code but the report does report using the original
    .coffee
    files at all. Am I missing some step(s) in order to ensure that the
    .coffee
    files are the ones used in the report to show the original code lines?
  • b

    bulky-sundown-74498

    06/27/2021, 4:01 PM
    Hi @User , I don't really understand what is happening and what you see. Could you please create a reproduction repository? It does not have to be super advanced. Actually the simpler the better. Just trying to understand. Thank you
  • w

    wooden-advantage-64510

    06/28/2021, 2:19 PM
    I'm running into an inconsistency issue with the Electron based runner. I'm running image based snapshot testing against mounted components (Cypress 6.9.0 based component testing). The base lines for the images are created on the developer machines which are all Mac OS devices and it works great between different Macs, but once we move to CI which is a linux environment we're starting to see issues with the Electron based runner where the dimensions of the screenshots created no longer match the base line images that were previously created causing our tests to fail. I managed to reproduce this issue locally by spinning up multiple Linux based VM's (CentOS and Linux) and they showed the same behaviour where the linux machines were producing inconsistent results. Initially I thought it was my custom screenshot setup and spend countless hours debugging it as I'm manually supplying the crop dimensions based on
    element.getBoundingClientRect
    and thought maybe OS based fonts were the curpit but that was a red herring. As a final effort I tried to just switch browsers to
    chrome
    expecting to see no change as Electron is based on Chromium I expected the same failures to happen. But everything passed. Does anyone have an idea what would cause Electron to behave differently on Linux, while Chrome is working flawless?
  • c

    chilly-island-52477

    06/30/2021, 4:41 PM
    Does cypress tie into visual studio builds? How do i set this up ?
  • b

    brief-kite-35331

    07/01/2021, 11:38 PM
    Hello guys! How do you use js files as fixtures? any examples on this? I tried this in user-details.js:
    Copy code
    data = {
      email: function () {
        const currentTimestamp = new Date().getTime();
        return `test${currentTimestamp}@test.com`
      },
      firstName: 'Max',
      lastName: 'Mustermann',
      street: 'Some Street',
    }
    Then in my spec file I do this:
    cy.fixture(env + '/user-details').as('userDetails');
    And in the
    it
    block of the test in the same spec file:
    Copy code
    const userDetails = this.userDetails.data;
    actions.insertStreet(userDetails.street);
    But it says it cannot read property 'street' of undefined. Any ideas how to do it properly? 😅
  • w

    wonderful-match-15836

    07/02/2021, 12:09 AM
    Hi @User this got me curious so I gave it a shot too, it looks like there are some outstanding issues with js fixtures and a workaround is shown here: https://github.com/cypress-io/cypress/issues/1271#issuecomment-818909021 I might not be very creative, I've only used json in my fixtures, so I'm not too sure of the nuance you might be working with. In your case it I wonder if it's ok to make a function that returns this object, and call it when you need the object created, instead of using a fixture? Or if somebody here knows a better way, we'll both learn 🙂
  • s

    salmon-oyster-49557

    07/05/2021, 6:27 AM
    I am having a hard time swiping list elements in Ionic-Vue. According to https://www.cypress.io/blog/2020/07/08/end-to-end-testing-mobile-apps-with-ionic-and-cypress/#accessing-app-storage (on Cypress
    4.7.0
    ), it works when it's not a list. From what I can tell, all my attempts click and drag the correct places, but no interaction with the element itself is happening. Are there any recent examples of swiping/dragging in a nested element? Here are some of the things I've tried (that look like they happen, but don't actually interact with the page) to drag a list item from right to left, to no avail: - Using
    'mousedown'
    ,
    'mousemove'
    , then
    'mouseup'
    - both in the same position and without options (which moves it back to the origin) - Specifying mouse buttons
    which: 1
    , like the https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__drag-drop/cypress/integration/drag_n_drop_spec.js example shows - Using
    position: 'right'
    then
    position: 'center'
    or
    'left'
    in
    .trigger()
    - Using
    clientX
    and
    clientY
    in
    .trigger()
    - Using
    dragstart
    ,
    dragenter
    ,
    dragleave
    ,
    drop
    in
    .trigger()
    - Using the
    cypress-drag-and-drop
    plugin (the one that's been fixed for cypress 7+ here: https://github.com/brunocavalcante/cypress-drag-drop/tree/cypress-7-support#options)
  • s

    salmon-oyster-49557

    07/05/2021, 6:31 AM
    For a reproducible test case, clone the example from the blog post (https://github.com/ceceliacreates/ionic-cypress) and add this as a new test or modify `cypress/integration/swipe.spec.js`:
    Copy code
    cy.disableTutorial(); // Goes straight to the list items
    
    cy.get('ion-list > ion-item-group:nth-child(1) > ion-item-sliding')
    // or this selector: cy.get('#main-content > ng-component > ion-tabs > div > ion-router-outlet > page-schedule > ion-content > ion-list > ion-item-group:nth-child(1)')
        .trigger('mousedown', {position: "right", force: true })
        .trigger('mousemove', {position: "center", force: true })
        .trigger('mouseup', {force: true})
    Tried a few other variations of
    mousemove
    in that repo, all had issues with
    is being covered by another element:
    - which I'm not seeing in my own attempts on Cypress
    7.6.0
  • b

    brief-kite-35331

    07/05/2021, 3:43 PM
    Thanks!
  • b

    brief-kite-35331

    07/05/2021, 3:50 PM
    hello guys! what would be the best way if I wanted to trigger the same API call twice? So the use case would be: 1. I click on the button which sends the API request 2. after this the button becomes disabled 3. I check/spy the request with the cy.intercept() and check that the status is 200 OK and so on 3. I want to initiate the API request again and check that the response is not 200 this time, but I cannot do this through UI since the button is disabled My question is: How to trigger that API call the second time? Any advice on this?
  • u

    user

    07/06/2021, 5:19 AM
    Hey everyone, I am having some trouble setting up Cypress with our CircleCI configuration. I have this in our config.yml
    Copy code
    - cypress/run:
        requires:
          - setup
        attach-workspace: true
        yarn: true
        build: "yarn cypress:dashboard"
        record: true
        parallel: true
        parallelism: 4
        context:
          - npm_tokens
        filters:
          branches:
            only:
              - develop
              - /feature-deploy-develop-.*/
    When it runs inside of Circle though I get an error saying
    Copy code
    The cypress npm package is installed, but the Cypress binary is missing.
    
    We expected the binary to be installed here: /root/.cache/Cypress/7.6.0/Cypress/Cypress
    
    Reasons it may be missing:
    
    - You're caching 'node_modules' but are not caching this path: /root/.cache/Cypress
    - You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
    
    Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
    
    Alternatively, you can run 'cypress install' to download the binary again.
    
    https://on.cypress.io/not-installed-ci-error
    
    ----------
    
    Platform: linux (Debian - 10.6)
    Cypress Version: 7.6.0
    In our setup command we are persisting a whole bunch of files to workspace but should I be adding something for the cypress? Looking at the
    cypress/install
    command it seemed like it would be just redoing the setup steps. Thanks in advance
  • s

    salmon-sandwich-36280

    07/06/2021, 8:25 AM
    hey i'm using cypress to do e2e testing for vue2 project , i would like to use it too for unit testing , i've tried to read the documentation and add cypress unit testing with e2e testing but it failed , cypress couldn't recognize my tests files , is there any way you could help me please !!
  • s

    salmon-oyster-49557

    07/06/2021, 5:12 PM
    Unit tests as in regular code logic testing? Or Vue components?
  • s

    salmon-oyster-49557

    07/06/2021, 5:14 PM
    You can technically run regular (code testing code, nothing visual or browser based stuff involved) unit tests with Cypress, but it's a bit unwieldy compared to using the regular mocha unit testing right in a terminal.
  • b

    brief-kite-35331

    07/07/2021, 3:28 PM
    Hello guys. I am trying to do the following:
    Copy code
    getCheckoutPricesBeforeApplyingVoucher() {
        let prices = {
          subtotalPrice: 0,
          totalPrice: 0,
          itemPriceOrderOverview: 0,
          totalPriceOrderOverview: 0,
          totalWithVATOrderOverview: 0
        }
    
        cy.get('[data-cy=subtotalPrice]').invoke('text').as('subtotalPrice');
        cy.get('[data-cy=totalPrice]').invoke('text').as('totalPrice');
        cy.get('[data-cy=itemPriceOrderOverview]').invoke('text').as('itemPriceOrderOverview');
        cy.get('[data-cy=totalPriceOrderOverview]').invoke('text').as('totalPriceOrderOverview');
        cy.get('[data-cy=totalWithVATOrderReview]').invoke('text').as('totalWithVATOrderReview');
    
        prices.subtotalPrice = this.subtotalPrice;
        prices.subtotalPrice = this.totalPrice;
        prices.subtotalPrice = this.itemPriceOrderOverview;
        prices.subtotalPrice = this.totalPriceOrderOverview;
        prices.subtotalPrice = this.totalWithVATOrderReview;
    
        cy.log(prices.subtotalPrice);
        cy.log(prices.totalPrice);
        cy.log(prices.itemPriceOrderOverview);
        cy.log(prices.totalPriceOrderOverview);
        cy.log(prices.totalWithVATOrderOverview);
        return prices;
      }
    The function getCheckoutPricesBeforeApplyingVoucher() is defined in separate class and gets called in my
    it
    block Basically get the price text from the UI elements and save it to the prices JS object. But for some reason all of the values on this object are 0. I don't know what could be the cause of it. Any ideas?
  • s

    steep-account-67575

    07/08/2021, 3:48 PM
    Hello everyone 🙂 I'm trying to call a function exported by my bundle via the global namespace but it looks like the function is not defined when calling it as part of the test spec. Do I need to use commands (or tasks?) to access the global scope of the application?
  • w

    wonderful-match-15836

    07/08/2021, 4:10 PM
    Hey Marijana, did you get this worked out? I see two potential issues - one is where you assign the values in your
    prices
    object - it repeats
    prices.subtotalPrice
    so only that property is getting set. But I wonder if there is some issue with the aliases being used right after they are initialized, I would have thought that those values take a hot second to resolve, and that you'd need a
    .then
    someplace before referencing them. I don't use aliases this way so I'm not sure without experimenting. Is
    subtotalPrice
    and everything else zero?
  • b

    brief-kite-35331

    07/08/2021, 4:17 PM
    @User hey, yes I got it right. Here is the question from SO where I posted my solution with aliases and also got another way with synchronous accessor. https://stackoverflow.com/questions/68288356/how-to-extract-text-value-and-assign-it-to-variable-outside-then-scope-in-cypres/68293617#68293617
  • b

    brief-kite-35331

    07/08/2021, 4:17 PM
    Thanks for reaching out!
  • b

    brief-kite-35331

    07/08/2021, 4:20 PM
    I would say aliases are safer way to go because of the overall asynchronicity. Even though the accepted answer looks cleaner. What do you think? @User
  • s

    steep-account-67575

    07/08/2021, 5:21 PM
    So I figured out that I can access some things via
    cy.window()
    but the returned object still doesn't seem to have any of the globals exported by my bundle. I'm probably missing something obvious here but I just don't know what 😅
  • w

    wonderful-match-15836

    07/09/2021, 2:49 PM
    I had never tried the synchronous accessor before reading that answer. It does seem like it pops you out of Cypress's world, into regular jQuery, so it would be very dependent on the exact DOM state at the time the line runs. Also I think the answer looked clean, sure, but it wasn't in the full context of the goals of your text so it's not really comparing like with like. The repeated conversion to Number with
    +Cypress
    is probably not a choice I'd have made, I'd probably make a helper to pass a selector and return the number if I needed that.
1...252627...252Latest