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

    famous-restaurant-30435

    07/14/2022, 3:12 PM
    I believe Cypress does this automatically, but you is Cypress re-initializing when you change the config file? You would have to restart it so it consumes the updated config.
  • a

    able-monkey-72947

    07/14/2022, 3:14 PM
    Ah, it goes in the root of the object you give to
    defineConfig
    ,
    Copy code
    module.exports = defineConfig({
      e2e: {...},
      experimentalInteractiveRunEvents: true
    }
  • f

    famous-restaurant-30435

    07/14/2022, 3:15 PM
    💥
  • a

    able-monkey-72947

    07/14/2022, 3:24 PM
    I'm a little confused about what's happening here, I maybe on the wrong track all together. In my config file I've got this node event -
    Copy code
    on('before:spec', (spec) => {
      console.log('!!!!! before:spec', spec)
    })
    When I start the test runner, not when I run the spec, I see this -
    !!!!! before:spec { name: '', absolute: '', relative: '', specType: 'integration' }
    . And then when I run the spec I don't see anything output?
  • a

    able-monkey-72947

    07/14/2022, 3:24 PM
    But let me back up - if I want to run a command immediately before every test (without having to call it in a
    beforeEach
    at the top of every test), is
    setupNodeEvents
    the correct place to be hooking into here?
  • f

    famous-restaurant-30435

    07/14/2022, 3:29 PM
    Well before:spec runs before each test file.
  • f

    famous-restaurant-30435

    07/14/2022, 3:29 PM
    Sounds like you want to run a command before every test?
  • a

    able-monkey-72947

    07/14/2022, 3:32 PM
    I think so?
  • f

    famous-restaurant-30435

    07/14/2022, 3:32 PM
    @able-monkey-72947 - You may want to use test:before:run if you need to run a command in every test
  • f

    famous-restaurant-30435

    07/14/2022, 3:34 PM
    https://docs.cypress.io/api/events/catalog-of-events#Cypress-Events
  • a

    able-monkey-72947

    07/14/2022, 3:34 PM
    Ultimate what I'm going for is reimplimenting this but for a different lifecycle in the app. We have this command that hooks into MSW for client side requests and saves them in a directory constructed from the currently running test, need to implement this for
    getStaticProps
    as well.
  • a

    able-monkey-72947

    07/14/2022, 3:35 PM
    10.3.0
    is telling me
    test:before:run
    isn't a valid event?
  • f

    famous-restaurant-30435

    07/14/2022, 3:36 PM
    Oh interesting. I wonder if I missed that in the change log?
  • f

    fresh-plastic-30342

    07/14/2022, 5:21 PM
    hello
  • f

    fresh-plastic-30342

    07/14/2022, 5:21 PM
    it("invokes the method getMe after clicking the button login", () => { cy.get(":nth-child(3) > .field-H34VB2 > .input > .input-Dp2Gzs").type( "mo@fff.cc" ); console.log("typed in email"); cy.get(":nth-child(4) > .field-H34VB2 > .input > .input-Dp2Gzs").type( "pass" ); //spy on a method getMe inside the imported api and check that it is called after clicking the button submit cy.spy(api.users, "getMe").as("getMe"); cy.get(".btn-DHeP1F").click(); cy.get("@getMe").should("be.called"); });
  • a

    adorable-smartphone-87280

    07/14/2022, 5:46 PM
    hello
  • b

    brash-ghost-16880

    07/14/2022, 7:35 PM
    Hi everyone So I am facing a problem with E2E testing. When i run it locally its fine but in CI pipeline its giving me error saying one div can not be found. Any idea what it could be?
  • b

    brash-ghost-16880

    07/14/2022, 7:38 PM
    Basically its the share with friends button. If its desktop view then there should be a copy link div after i click on the share button. So i am using viewport to make sure its desktop view but still link sharing is not available. I am guessing its not getting the desktop view somehow and so the share button is not opening the copy link option.
  • b

    brash-ghost-16880

    07/14/2022, 7:39 PM
    But as i said its working when i test locally but in gitlab CI its giving the error.
  • a

    adorable-smartphone-87280

    07/14/2022, 7:39 PM
    What happens when you run it headlessly on local?
  • a

    adorable-smartphone-87280

    07/14/2022, 7:40 PM
    cypress run not cypress open.
  • b

    brash-ghost-16880

    07/14/2022, 7:41 PM
    yeah runs correctly without error
  • a

    adorable-smartphone-87280

    07/14/2022, 7:43 PM
    Are you able to view a recording video of your CI runs?
  • b

    brash-ghost-16880

    07/14/2022, 7:45 PM
    not sure how to do that since i dont have idea on CI system
  • b

    brash-ghost-16880

    07/14/2022, 7:46 PM
    its using docker container so would be tricky
  • a

    adorable-smartphone-87280

    07/14/2022, 8:06 PM
    You aren’t using the Cypress Dashboard I assume?
  • b

    brash-ghost-16880

    07/14/2022, 9:04 PM
    yes i just setup the dashboard to see the result. and its interesting. i am not even sure what is happening cause the video is not full. I mean the video is finished before it gets to the error part. The screenshot shows the error and its the same and i can not understand the issue since video is not complete.
  • c

    careful-computer-31749

    07/14/2022, 11:50 PM
    well the thing i that ipcMain in electron receives an scanned value through node-ipc and then it send to ipcRendender and it send data to electron window . Is it even possible to mock the scenario in cypress. I want to send scan value in cypress window when ever I nedd
  • a

    adorable-smartphone-87280

    07/15/2022, 1:16 AM
    I would have to see code to be able to debug further.
  • s

    some-park-44701

    07/15/2022, 6:07 AM
    Is there a good way to reuse flows? Let's say I have a flow test that looks like this
    Copy code
    TypeScript
    it('tests some flow', () => {
      cy.login('some_user_name');
      cy.some_cool_custom_command();
    })
    Now, instead of testing it with just 'some_user_name', I have a list of perhaps 40 different roles that needs to use that custom command in the flow. For the sake the argument, whatever is done in beforeAll and afterAll must be run for each for the tests. Is there a good way to reuse the test instead of having to write the same flow 40 times?
    b
    • 2
    • 1
1...697071...192Latest