How We Perform Frontend Testing on StackPath’s Customer Portal
Publikováno: 15.11.2019
Nice post from Thomas Ladd about how their front-end team does testing. The list feels like a nice place to be:
- TypeScript - A language, but you're essentially getting various testing for free (passing the right arguments and types of variables)
- Jest - Unit tests. JavaScript functions are doing the right stuff. Works with React.
- Cypress - Integration tests. Page loads, do stuff with page, expected things happen in DOM. Thomas says their end-to-end tests (e.g. hitting services) are
The post How We Perform Frontend Testing on StackPath’s Customer Portal appeared first on CSS-Tricks.
Nice post from Thomas Ladd about how their front-end team does testing. The list feels like a nice place to be:
- TypeScript - A language, but you're essentially getting various testing for free (passing the right arguments and types of variables)
- Jest - Unit tests. JavaScript functions are doing the right stuff. Works with React.
- Cypress - Integration tests. Page loads, do stuff with page, expected things happen in DOM. Thomas says their end-to-end tests (e.g. hitting services) are also done in Cypress with zero mocking of data.
I would think this is reflective of a modern setup making its way across lots of front-end teams. If there is anything to add to it, I'd think visual regression testing (e.g. with a tool like Percy) would be the thing to add.
As an alternative to Cypress, jest-puppeteer is also worth mentioning because (1) Jest is already in use here and (2) Puppeteer is perhaps a more direct way of controlling the browser — no middleman language or Electron or anything.
Thomas even writes that there's a downside here: too-many-tools:
Not only do we have to know how to write tests in these different tools; we also have to make decisions all the time about which tool to use. Should I write an E2E test covering this functionality or is just writing an integration test fine? Do I need unit tests covering some of these finer-grain details as well?
There is undoubtedly a mental load here that isn’t present if you only have one choice. In general, we start with integration tests as the default and then add on an E2E test if we feel the functionality is particularly critical and backend-dependent.
I'm not sure we'll ever get to a point where we only have to write one kind of test, but having unit and integration tests share some common language is nice. I'm also theoretically opposite in my conclusion: integration/E2E tests are a better default, since they are closer to reality and prove that a ton is going right in just testing one thing. They should be the default. However, they are also slower and flakier, so sad trombone.
Direct Link to Article — Permalink
The post How We Perform Frontend Testing on StackPath’s Customer Portal appeared first on CSS-Tricks.