We just started using Cypress to test our component library in Storybook. We write our integration/functional tests in Typescript. Unit tests are written elsewhere.
I'm struggling with the organization of the tests, I come from the Selenium world where I used to use POM approach. Currently, I have one spec file named [Componenent].test.ts (we don't use spec as we noticed it's usually reserved for unit tests).
Currently, each test file contains a bunch of functions and constants declared at the top that are used by the tests. If we take a Grid as an example, these functions are mainly to retrieve a row, a tooltip, edit a cell, etc. so that we centralize the selectors and don't duplicate code.
Soon we want to add accessibility tests and visual tests for these components. Therefore, I have a few questions.
I could write all these tests within the same test file as the functional tests. I'm not a fan of this approach, because it’s messy and if I want to run just the accessibility tests or visual tests then I can’t isolate them with
“–spec“to only run themI want to create separate test files for visual and accessibility tests that I would drop in a different folder so in the end I would have the following folders: integration, accessibility, visual I would also need to append something to the test file name to know what type of test it is. My main question is how do I reuse the functions and commands within all these files? My 3 component test files will need to use the same constants, functions, etc...
I don’t think Typescript supports hierarchical inheritance and I keep hearing I should not use POM. I also noticed I could write them in the functional test file and export them and import them in the two other files but not sure if it’s the right approach. I’m new to this as you can see.
Suggestions, please?