prettier-browser-extension
prettier-browser-extension copied to clipboard
Add tests
Once the basic functionality has been sorted out, we should split the code into smaller modules and add some tests.
Nice, I was just thinking about this. I feel like since we have so many edge cases with site support (even with only GitHub and Stack Overflow for now), end to end tests with Cypress could be really useful for regression testing. Also we won't need to restructure code for end to end tests, assuming there's a way to install extensions. It still may be useful to have some unit and integration tests though.
Agreed this would be good to do, although I'm not sure how easy it would be to achieve with Cypress as there are some pretty specific edge cases that I don't know how you could simulate. (At least without just using static web pages)
i.e: Creator of an issue see's a special button when commenting, Owner/Maintainer of a project see's special buttons when commenting on PRs (same with issues) ..etc
I think it would also be good to have some unit tests too though.
It's possible to install a Chrome extension in Cypress, but we may still need to mock the chrome APIs and extension URLs. I'm giving this a try, and if it's too difficult to get something working without complex mocks, I might switch to something like Puppeteer or Selenium.
I've tried Cypress and Puppeteer, but they don't seem to support what we need to fully test the extension. Selenium works, but we'd have to authenticate a GitHub account in the tests as the extension only works logged in. I think integration/unit testing would be a better approach, I'm making progress with Jest.
Anyone should be able to start setting up some Jest tests based on #81, but I still have a few in-progress tests that I need to figure out. Please let me know if there's anything you plan on testing so we can coordinate, and only mock/stub what's needed for test environment support so we can keep tests as realistic as possible.
Here are my test plan ideas so far (some of which I've already started implementing):
- Integration test classes and functions in
src/contentwith dom-testing-library and jest-dom - Integration test React components in
src/optionswith react-testing-library and jest-dom - Unit/integration test other stuff as needed (I've already tried end to end tests and it's not worth it: Chrome extension support is limited in most frameworks, and even when it's not, it's a pain to deal with GitHub auth)