Tests
The test framework is Vitest. The tests are in tests/, and vitest.config.ts configures them.
vitest.config.tsuses the pluginWxtVitestfrom WXT. The plugin gives each test the same environment as the extension code: the automatic imports, andbrowserbound to@webext-core/fake-browser. Thus a test can importlib/throttle.tsdirectly.- No test opens a browser, and no test sends a request to patreon.com.
tests/throttle.test.tswaits for real time, because a delay is the subject of the test. It needs approximately 20 seconds. The timeout invitest.config.tsis 60 seconds.tests/normalize.test.tsreads.api-dumps/. Git ignores that directory, thus a new copy of the repository has no recorded answer. The tests then report as skipped and give the command that records one. They do not fail.- The tests print nothing that comes out of a dump. A test name has no campaign ID, and each assertion becomes a count or a boolean before Vitest sees it. Vitest prints the value that an assertion received when the assertion fails, and that value can be account data (see rules for account data).
npm run normalize:check,npm run throttle:check, andnpm run docs:checkeach run one test file. Use them when you change one area.
Write each new test in tests/, with the name <area>.test.ts.