vitest-cucumber icon indicating copy to clipboard operation
vitest-cucumber copied to clipboard

Guide on creating idompotent tests using React Testing library

Open charlieforward9 opened this issue 9 months ago • 10 comments

With only a few months under my belt with BDD/TDD, I am still learning how to structure these tests to be valid and isolated from each other.

With the Feature/Scenario hierarchy, I am still figuring out how to test unique capabilities (scenarios) of a component (feature) within the same test file without having overlap between scenarios.

For example, when testing a search bar, I type abc and then check for results. In the next scenario, I would type def. However, I am having an issue where it does not reset the previous scenario and I get abcdef in the search bar. I ham including Before/AfterEachScenario hooks, but it would be nice to have some sort of auto reset if we are using the React Testing Library render method

I will continue developing and possibly make a template repo for this if I figure it out.

charlieforward9 avatar May 17 '24 15:05 charlieforward9