I’m trying to re-learn my automation skills with cypress as I have eight months remaining in this manual role and I am hoping I can use a repository to demonstrate my skills & use it as a guiding template for future automation projects.
Unfortunately, the company I work with doesn’t have any developers within the org and I don’t have any close contacts who deal with Cypress.
If possible, could someone give me some pointers on whether I am doing things correctly or not?
P.S be harsh if you have to, I need to learn!
At the moment I am starting small and basic with SauceDemo, once I add improvements to my next project I will add methods of authentication, API and better containerisation.
I am not an expert but here are a few things I observed.
You would be better creating a .gitignore file and adding node_modules. This can help with reducing repository size and avoid version conflicts etc. There are a couple of other reasons so have a read into it.
Formatting in commands.js could be nicer. Mix of single ’ and " used throughout. Some spacing inconsistency as well. This seems a common theme between the files. Plenty of information online around best practices.
I don’t think you need to call cy.clearCookies() in the tests. Based on the docs this gets reset on each run due to test isolation being true by default.
Personally I would try to make some of the tests a bit more atomic. For example inventory.cy.js:
Login using Cypress Session - this would allow you to stay logged in for all tests saving time. You could also shift all the code to 1 login command.
Click the inventory items
Assert you have navigated to the correct page etc
Then for for the next test navigate directly to the correct inventory url and assert the image and text etc.
That is a useful video and look into, this will go in hand with the TAU course and hopefully, it will increase my confidence in testing and less flaky tests in general. Thank you so much!