gatsby-plugin-favicon
gatsby-plugin-favicon copied to clipboard
Add unit tests
Since testing this plugin by hand is a pain (looking at generated favicons folder and generated/injected html source), it would be nice to add unit tests.
GatsbyJS uses https://facebook.github.io/jest/ for all its tests. Perhaps we could also use this library, which I have never used before, but want to learn.
It would be great! I've never used it myself neither, but feel free to open a PR if you look into it before I find some time to do so :)
Maybe we should begin with some tests to test the following things:
- All favicons are generated with standard configuration
- Check the output HTML file
- Maybe a last one with a custom path to find the source file?
Yeah would be great, I am very new to writing unit tests, would be a great way to learn it.
Afaik, unit tets should only test the core functionality of piece of software. So the core functionality of this plugin is, that it takes a snippet of configuration, parses it and sends it to other functions, which do the actual work. We can trust, these functions are tested somewhere else and view them as working.
So imho, we only need to write tests, that the plugin is invoking modifyWebpackConfig
and setHeadComponents
with correct arguments, which are generated from the different config combinations.
Yes you're right, we should start with some unit tests that are strictly testing the code included in the plugin. Then, later, we could consider having an integration testing to test the whole feature, but indeed they are not the same and we can start with the first one.