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

    bulky-sundown-74498

    06/04/2021, 7:19 PM
    the babel plugin
  • h

    handsome-kilobyte-99728

    06/04/2021, 7:20 PM
    ahhh yeah
  • h

    handsome-kilobyte-99728

    06/04/2021, 7:20 PM
    So i can open an issue about not returning
    config
    and incompatibility with react-refresh if that would be helpful.
  • h

    handsome-kilobyte-99728

    06/04/2021, 7:22 PM
    looks like a few people have had the same issue 🤔
  • b

    bulky-sundown-74498

    06/04/2021, 7:37 PM
    How do you know ?
  • b

    bulky-sundown-74498

    06/04/2021, 7:39 PM
    I am guessing you found a few issues in the GH repo
  • b

    bulky-sundown-74498

    06/04/2021, 7:39 PM
    would you mind sending me the links?
  • f

    flat-electrician-52949

    06/04/2021, 8:12 PM
    Anybody got some good examples with component-testing and
    cy.clock()
    ?
  • e

    echoing-piano-69699

    06/04/2021, 9:05 PM
    Am I missing something for how to properly test this?
  • h

    handsome-kilobyte-99728

    06/04/2021, 11:08 PM
    I saw these two: https://github.com/cypress-io/cypress/issues/16807 https://github.com/cypress-io/cypress/issues/16812
  • f

    flat-electrician-52949

    06/05/2021, 7:00 PM
    I have tried to chain the
    cy.clock
    with the
    tick
    Copy code
    jsx
    it.only('shows an estimate on when it is ready (fulfilled)', () => {
        const now = new Date()
    
        mount(
          <ResizeWrapper>
            <CartProvider>
              <PaymentSucceededMessage />
            </CartProvider>
          </ResizeWrapper>
        )
    
        // Time left
        cy.clock(now)
          .contains('10 min', { matchCase: false })
          .should('be.visible')
          .tick(1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/ + 300 /*ms*/)
          .contains('9 min', { matchCase: false })
          .should('be.visible')
          .tick(1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/ + 300 /*ms*/)
          .contains('8 min', { matchCase: false })
          .should('be.visible') // FIXME: The test does not work but the real life version does
    
        // Note about the timing can differ if the order asked it to be ready at another time
        cy.contains('Om du inte har angett en annan tid i anteckningen till köket')
      })
    But then it complains about a global
    window
    object
  • f

    flat-electrician-52949

    06/05/2021, 8:18 PM
    hmm.. looking at the comment in this https://stackoverflow.com/q/59585375/618099 it appears that the
    cy.tick
    has a bug
  • f

    flat-electrician-52949

    06/06/2021, 5:44 AM
    Found out that a
    cy.wait(0)
    was needed in between the ticks.
  • f

    flat-electrician-52949

    06/06/2021, 5:45 AM
    https://stackoverflow.com/a/67855430/618099
  • b

    billowy-spoon-30011

    06/07/2021, 1:07 PM
    @User so far no luck, thanks again for the link
  • b

    billowy-spoon-30011

    06/07/2021, 2:23 PM
    I'm still feeling I'm close enough of the solution but it's taking my actual clipboard and clicking on the button doesn't seem to change its value with the URL I want to use
  • l

    limited-keyboard-75773

    06/08/2021, 4:50 PM
    I'm trying to use
    cy.exec
    function in a custom module
    js
    file. Is there a way to have access to this function outside of Cypress? I'm getting this error:
    ReferenceError: cy is not defined
    . I tried explicit import it like so
    import { cy } from 'cypress';
    but I get another error:
    SyntaxError: The requested module 'file:///path/to/node_modules/cypress/index.js' does not provide an export named 'cy'
    . I'm trying to use node native for both
    cy.exec
    &
    cy.readFile
    but no luck with native
    exec
    from Node.js
  • b

    bulky-sundown-74498

    06/08/2021, 4:54 PM
    Hello Manuel, the cy variable is instanciated when cypress tests are initialized. I believ you might actually be looking for...
  • b

    bulky-sundown-74498

    06/08/2021, 4:54 PM
    https://github.com/sindresorhus/execa
  • l

    limited-keyboard-75773

    06/08/2021, 4:57 PM
    Thanks Bart! I would rather avoid importing a plugin for this if I can. Quick question,
    cy.exec
    uses
    execa
    under the hood? I replaced
    cy.readFile
    with
    fs.readFile
    & worked like a charm so I thought
    cy.exec
    was based on
    childProcess
    on Node.js. Is this correct?
  • b

    bulky-sundown-74498

    06/08/2021, 4:58 PM
    What do you want to do?
  • b

    bulky-sundown-74498

    06/08/2021, 4:58 PM
    Do you want to automate a process?
  • l

    limited-keyboard-75773

    06/08/2021, 4:59 PM
    Basically, I'm migrating some unit tests that they were written using
    Cypress
    to
    mocha
    native. We used the command
    cy.exec
    to execute a
    Node's script
    . I am just looking for the equivalent without using
    cy.exec
    or either finding a way to have access to the
    cy
    object
  • b

    bulky-sundown-74498

    06/08/2021, 5:01 PM
    So you would like to run those tests outside of the cypress runtime
  • b

    bulky-sundown-74498

    06/08/2021, 5:02 PM
    Do you mind if I ask why?
  • b

    bulky-sundown-74498

    06/08/2021, 5:02 PM
    Just curious
  • l

    limited-keyboard-75773

    06/08/2021, 5:03 PM
    Yes, these unit tests will be triggered by Jenkins job. If I'm correct, I have two options: - Either find the equivalent to
    cy.exec
    natively using Node.js or using
    execa
    module (which I would love to avoid installing another dependency) - or finding a way to have access to
    cy
    object, which I think you just told me it's impossible?
  • b

    bulky-sundown-74498

    06/08/2021, 5:03 PM
    and yes cy.exec is based on childProcess
  • b

    bulky-sundown-74498

    06/08/2021, 5:03 PM
    https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/exec.js
  • l

    limited-keyboard-75773

    06/08/2021, 5:04 PM
    I would love to know the same thing 😆 My quess is that we have two kind of unit tests in our repo. One based on Cypress & another based on Mocha. We're looking to probably standardized them to one way
1...222324...252Latest