wikitree / wikitree-browser-extension

Browser extension that adds advanced features to WikiTree.com.
MIT License
25 stars 20 forks source link

Come up with a testing strategy. #2

Closed jmegenealogy closed 1 year ago

RobPavey commented 1 year ago

One approach (that I use in the Sourcer and AGC extensions) is to use node.js to build a testing framework.

The way I do this means that only the browser independent modules get tested by the automated tests. The code that modifies web pages or builds menus is not tested.

There may be other ways that would allow everything to be tested. Perhaps using a headless browser and something like puppeteer.

That said, for my extensions, the node.js framework has worked really well and is simple. The only library I use is jsdom.

RobPavey commented 1 year ago

I should also mention that there is a difference between unit tests and regression tests. What I use in AGC and Sourcer are regression tests. I store a lot of input data (WikiTree profiles and external record pages etc) and I store the reference output for that input with a given set of options. Running the tests compares the current output with the reference output and reports errors if they differ. This has worked really well for me. When a significant new bug is reported I add that case to the regression tests so the tests build up over time.

In contrast unit tests are usually a collection of code that tests small areas of the code (e.g. functions or modules). They can be time consuming to develop and can easily get out of date as the code changes, so maintaining them has a cost.

jmegenealogy commented 1 year ago

Once Przemek is done with his major changes to the code, I'll start looking at writing some tests.

RobPavey commented 1 year ago

I will be trying to integrate my existing tests as part of integrating AGC. Do we want a single framework for testing all features? Or can each feature have its own system? One framework would be best but I'm not sure if all features can be tested in the same way.

Maybe I can just get my agc tests incorporated in the simplest possible way and that gives us something to look at to consider the best way forward?

jmegenealogy commented 1 year ago

Ideally, we would have one framework for testing all features.

It would be helpful to have your agc tests as a starting point.

RobPavey commented 1 year ago

I have submitted a PR here: https://github.com/wikitree/wikitree-browser-extension/pull/55

This is the test system for the AGC feature. We can decide whether to build a framework around this style of testing or whether something else is required to test other features.

RobPavey commented 1 year ago

There is some good discussion of this in this PR: https://github.com/wikitree/wikitree-browser-extension/pull/97

PeWu commented 1 year ago

I added a sample feature DOM test in #117

shogenapps commented 1 year ago

Done.