Skip to content

jdegand/testing-router-outlet

Repository files navigation

Testing Router Outlet

Angular Challenges #17 Router Testing

Built With

Thoughts

  • Cypress 13 is a mess right now (Sept 2023).
  • I think the lazy loading of the search component causes the button to not appear as disabled and prevents the error class from being in the dom on the initial load. Testing-library sees fallback html without either thing being set.
  • Thus, you need to do something to get the component to re-render.
  • screen.debug() is extremely useful.
  • When running the app, you don't have to click the link to show the form like you have to do in cypress.
  • There is a weird disconnect between actions necessary for tests but not when you run the app.
  • I was tempted to add selectors to the html at points. The selectors I used are mostly generic and a developer possibly would have to change them if the app were to be reworked.
  • When using jest with angular, there are issues with using modules. You have to use a different jest.config and add other properties to the tsconfig.spec.json. Even with all the extra boilerplate, I've had problems getting a configuration that works reliably. I think module testing errors could be library-specific.
  • With jest tests, you get a warning error - Error: Not implemented: navigation (except hash changes). Need to investigate more.
  • It may have been better to vary test queries more but I think the challenge has a compare and contrast element to it. (Testing-Library vs Cypress)

How to Use

git clone https://github.com/jdegand/testing-router-outlet.git

# cd into the directory
npm install

# Jest 

npm test

# Jest with Coverage

npm run test:coverage

# Cypress

npm run cypress:open

Useful Resources

About

Angular Challenges #17 Router Testing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published