gdirk07 / PokemonChecker

Playing around with APIs
https://gdirk07.github.io/PokemonChecker/
0 stars 0 forks source link

Advance testing #89

Open gdirk07 opened 2 years ago

gdirk07 commented 2 years ago

While we are writing Unit Tests, I think integration tests are something we should look at next since actions in one component will affect another, and the view will be affected. For example, a change in PokemonDisplay caused the app to no longer fetch abilities. I think it makes sense sooner than later to look into view testing to make sure the correct information is being display. I know Jest has snapshots I'm not sure if that's what we're looking for.

jeremy-jtlo commented 2 years ago

I've had some mild success using Cypress for doing screenshot diffs and validating functionality (spawn a view with stub data, click on things, check the results), it might be worth investigating here. Cypress will run in a chrome tab and show live DOM updates, which does a lot more for tracking the render process than running Jest and praying things look correct.

I do agree that we'll want something a bit more robust than the unit tests moving forward, but a view causing a data fetch to fail feels like a bigger root issue that simple testing might not catch (we generally want to avoid calling the live API during a test).

jeremy-jtlo commented 2 years ago

If you want to read up on cypress, their site is available here:

https://www.cypress.io/

gdirk07 commented 2 years ago

I agree that there is a bigger root issue, but being able to catch it might be difficult, especially if the app gets bigger and bigger so having something in place could help and might be worth looking into

gdirk07 commented 2 years ago

I played around with Cypress a bit, some thoughts

  1. Its very nice and sort of what I'm looking for as I can test with more depth than unit testing
  2. It supports typescripts but I think we need a local tsconfig for cypress directory as it uses some jest namespace causing a conflict with the compiler
  3. I still want more time to play around with it so I won't try to merge it but I will publish the branch for Testing-CypressSpike