mainIine / foe-helfer-extension

FoE Helfer - Extension for chromium based browsers and Firefox ;-)
https://foe-helper.com
GNU Affero General Public License v3.0
119 stars 181 forks source link

Add automated testing. #2726

Open AlfonZ42 opened 6 months ago

AlfonZ42 commented 6 months ago

Test environment

Tests are using Jasmine framework.

Tests are run by /test.html, accessed directly within the extension.
For example, run in the console (on a loaded game page): copy(extUrl + 'test.html'), paste copied link into a bookmark.

This has several consequences:

Files & Folders organisation

/test.html

The tests specs runner. Loads Jasmine, FoE Helper modules, test modules.
Tests are now run on foe-helper#loaded event, as the original load event is unreliable for this purpose - frequently load is fired earlier than foe-helper#loaded, resulting in unresolved references.
Currently test modules are linked directly here. See TODO below.

/vendor/jasmine

Jasmine framework files.
Should a file need to be altered, it is copied and altered into /test, with a copy left here for reference.

/test

Common and shared files.

testtools.js, testtoolsspecs.js

Test tools / utilities with their own tests.

/js/web/${modulename}/test/

Test specs for a particular module.

From the topmost suite name it should be easy to identify/locate the file the suite is in.
tt.getModuleSuiteName() was implemented to facilitate that, returns the filename it is used in. This assumes there is an association between test module filename and the module it belongs to.
Thus the recommended filename is modulename.js. Also see TODO below.

Known limitations / issues / things to do