Cypress Tutorial: Login Once with cy.session() for faster tests

Поделиться
HTML-код
  • Опубликовано: 1 дек 2024

Комментарии • 61

  • @NicolasLeblanc-z7s
    @NicolasLeblanc-z7s 8 месяцев назад +1

    I just LOVE that you showed how to do it "the best practise way". IE: Watching your video, I learned how to use command.js
    Thanks a bunch !

    • @CommitQuality
      @CommitQuality  8 месяцев назад

      Love to read these type of comments! Thank you

  • @arthurivex2298
    @arthurivex2298 Год назад +6

    Thank you, this helped. I had over 600 tests, and now I'm saving a ton of time simply because of cy.session(). Thanks again!

  • @envo2199
    @envo2199 Год назад +5

    Exactly what i was looking for, it was hard to understand the docs about this. You explained it very well ❤❤

  • @abubakrmirzaliev2497
    @abubakrmirzaliev2497 Месяц назад

    Hey man! great video, helped a lot! dispersed a lot of confusion in my mind! Than you very much!

  • @alexeyhimself
    @alexeyhimself 4 месяца назад

    Instead of cy.visit('/'); in every test we can also add to a login() function right after the session block cy.login('/'); and now we can write tests without that cy.visit('/'); as well. Thank you for tutorial!

  • @JuanJoseCortesGuzman333
    @JuanJoseCortesGuzman333 5 месяцев назад

    Wow, this was really useful, thank you for the video very clear explanation!

  • @matthew_jw1318
    @matthew_jw1318 7 месяцев назад

    Nice video. So easily explained compared to other videos.

    • @CommitQuality
      @CommitQuality  7 месяцев назад

      Thank you for the great comment :)

  • @samuelcacador
    @samuelcacador Год назад

    Great explanation! Thank you very much!

  • @oleksandrostapchuk5752
    @oleksandrostapchuk5752 Год назад

    Great video and explanation! Thank you!

  • @anaisry
    @anaisry 8 месяцев назад

    Amazing, Thanks a lot u safe my test

  • @cartagenadaniel1973
    @cartagenadaniel1973 10 месяцев назад

    Perfect video! Just need to expand for Dotenv. No hard coding.

  • @AmanUllah-ps1nk
    @AmanUllah-ps1nk Год назад

    Thankyou for this great effort !!

  • @himansrivastava
    @himansrivastava 11 месяцев назад

    Awesome! Thanks!

  • @NarendraMehta-r3w
    @NarendraMehta-r3w Год назад

    Great job, it helped me a lot!
    Thanks :)

    • @CommitQuality
      @CommitQuality  Год назад

      Thanks for the kind comment. Glad to have helped

  • @Another0neTime
    @Another0neTime Год назад

    Great videos my friend. Thanks for sharing!

    • @CommitQuality
      @CommitQuality  Год назад

      Thank you for the kind words and support!

  • @5906646
    @5906646 8 месяцев назад

    Perfectly done. Thanks a lot, mate!

  • @gabrielbatocchiocondedeoli8395
    @gabrielbatocchiocondedeoli8395 5 месяцев назад

    nice video bro

  • @chinthakawagawaththage467
    @chinthakawagawaththage467 6 месяцев назад

    This is a Gem

  • @saravanakumara3932
    @saravanakumara3932 5 месяцев назад

    hey, if i close the cypress runner and reopen and run the test, it is coming as session is creating but the whole cypress is got refreshed, so I won't be able to properly cache the session, so login got fail, pls help with this

  • @DilawarKhan-k4k
    @DilawarKhan-k4k 2 месяца назад

    In order to use cy.session(), provide a setup as the second argument:
    cy.session(id, setup)
    Because this error occurred during a before each hook we are skipping all of the remaining tests.

    • @DilawarKhan-k4k
      @DilawarKhan-k4k 2 месяца назад

      facing this error on cypress console

  • @amritharavikumar9760
    @amritharavikumar9760 5 месяцев назад

    Hi, When I use npx cypress open if I login once for the other spec files I am logged in automatically. But when I run using npx cypress run the login is happening for every spec files

  • @AlineCristineFadel
    @AlineCristineFadel Год назад +1

    Tks for the video! But how is session () possible when logging in via API? Because I don't use visit() on my tests.

    • @Sneferu9
      @Sneferu9 7 месяцев назад

      This is what I'm trying to do. Did you manage to make it?

  • @BrandonChawane
    @BrandonChawane 7 месяцев назад

    How would i run tests that depend on each other, sequentially, without logging on before each test? So i execute test1 and then test 2 and so on, without having to logon

  • @GeisserGomezUrquiza
    @GeisserGomezUrquiza Год назад

    Excellent! I wonder which Cypress version is it? I'm trying to introduce cy.session() in my tests using v10.11 and there are several challenges. Keep isolation:false, experimentalSessionAndOrigin:true, but I can't restore the session in the next spec file. Cypress create a new one. I would appreciate whatever opinion on this. Thanks!!!

  • @princePCR
    @princePCR Год назад

    thanks for this!

  • @k6Coder
    @k6Coder 4 месяца назад

    Thank you for the very helpful video.
    How to solve this one?
    So I have website
    I login with UI
    (it adds a cookie)
    I close the Cypress and open again
    Now I don't want to login again, I want to inject the cookie inside the browser and visit my user area
    Could you please share how we can solve this?
    Thank you

  • @jopadjr
    @jopadjr 6 месяцев назад

    Hi, I have a quick question. I am using an internal URL (this is running in the browser) using cy.visit() but Im getting this error :A connection to the upstream proxy could not be established: ERR_EMPTY_RESPONSE: The upstream proxy closed the socket after connecting but before sending a response. Can you please advice on what needs to be done in running an internal url? Thanks in advance.

  • @LM_ID-sb3ky
    @LM_ID-sb3ky 8 месяцев назад

    can you help me i am facing issue Cy.vist in it block gives error

  • @penguinCoder-kt9bn
    @penguinCoder-kt9bn 8 месяцев назад

    This is very helpful. Was wondering if you know a way to cache cy.visit('/') since going to '/' will take up of resource. Like you mentioned, in each test we need to specify cy.visit('/')

  • @sharmak2746
    @sharmak2746 9 месяцев назад

    Thanks a lot for this video and its a great help. Amazing. Can i request one video where we can longin using Microsoft authentication or multi domain and returns to application. Basically application is authenticated using Microsoft authentication. I have reached out multiple places. I feel you are the right one to help. Appreciate of you can share a video on this and it really helps UI automation using Cypress. Thanks again and looking forward for your video

    • @CommitQuality
      @CommitQuality  8 месяцев назад

      Yes I can try to create one. I would need to find a suitable test website to do this first though

    • @tharunv3952
      @tharunv3952 6 месяцев назад

      Hello @sharmak2746 , i am also facing the same problem , did your issue resolved ? please do comment, thanks

    • @sharmak2746
      @sharmak2746 6 месяцев назад

      @@tharunv3952 no, not yet unfortunately.

  • @dr9mm72
    @dr9mm72 Год назад

    How am I not seeing any Describe block in the code ?

  • @Top10ShortsMania
    @Top10ShortsMania Год назад

    I got this error "experimentalSessionSupport is not enabled. You must enable the experimentalSessionSupport flag in order to use Cypress session commands"

  • @metarun3
    @metarun3 Год назад

    Thank you so much for this video really helpful. I have a question currently i am using bdd page object model in cypress in typescript and i am passing username in feature file i want that all users which i am goanna use should login first and save the session before any tests run is this something possible ?

    • @CommitQuality
      @CommitQuality  Год назад

      If you're using cucumber JS as your BDD tool, look into hooks, before all sounds like you may want that one

  • @69treta
    @69treta Год назад

    Thanks!

  • @schmoukerclement3927
    @schmoukerclement3927 Год назад

    Hey great but how is having the username and password readable as string in the codebase considered good practice ? Anyone that gains access to your git repo for any reason (pentest or stuff like that) will have those credentials. Any way to get around this issue ?

    • @CommitQuality
      @CommitQuality  Год назад +1

      It's not best practice, this video is just to show the basics. Ideally you would use your preferred method of secure retrieval. I current use azure keyvault for mine, however you can use anything. Even git secrets may be something for you to look into

  • @shahulshas79
    @shahulshas79 Год назад

  • @ranvijayupadhyay3987
    @ranvijayupadhyay3987 Год назад

    Can u share me code

  • @pugnate666
    @pugnate666 21 день назад

    Make sure not to log credentials! Don't create a security risk with testing and hide them away with "type(password, { log: false });"
    The cypress example does not follow it's own recommendations.

  • @sufiyanali3144
    @sufiyanali3144 Год назад +2

    hey i don't know why but this isn't working for me, in 'it' block i am adding cy.visit('/') it goes back to login page if i dont add it, it doesn't go anywhere.. help me resolve this

    • @CommitQuality
      @CommitQuality  Год назад

      Can you provide your full code please? I'm happy to take a look for you