gatsby-plugin-favicon icon indicating copy to clipboard operation
gatsby-plugin-favicon copied to clipboard

Add unit tests

Open mperkh opened this issue 7 years ago • 3 comments

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.

mperkh avatar Nov 08 '17 12:11 mperkh

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?

julien1619 avatar Nov 30 '17 15:11 julien1619

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.

mperkh avatar Dec 04 '17 12:12 mperkh

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.

julien1619 avatar Dec 04 '17 13:12 julien1619