And don't skip alerts in Zotero.alert() during automated tests. (That
was intended to avoid long timeouts after unexpected failures, but,
e.g., PDF metadata lookups (which are currently disabled in automated
tests) should just be mocked so they don't intermittently fail.)
We don't want auto-sync to try to run during unrelated tests.
Additionally, even though the sync process wouldn't actually start due
to the absence of an API key (which is injected directly into the sync
functions for sync tests), since auto-sync kicks off after a one-second
delay on pane open, during tests the Zotero object has often been torn
down by the time the check code runs, producing spurious errors in the
console.
Mozilla file functions (OS.File.move()/copy(),
NetUtil.asyncFetch/asyncCopy()) can leave file descriptors open for a
few seconds (even with an explicit inputStream.close() in the case of
the latter), so a source installation that copies ~500 translators and
styles (with fds for source and target) can exceed the default 1024
limit.
(Mocha has a 'bail' config flag that's supposed to do this, but it doesn't seem
to work when passed to mocha.setup() (maybe because we're setting a custom fail
handler?), so this just calls abort() on the runner manually.)
Add functions to generate sample data for various formats
* Zotero Web API JSON (Zotero.Item::toJSON)
* CiteProc-JS JSON
* Export translator JSON
* Direct serialization of Zotero.Item fields
Add a way to load sample data into DB from JSON
Add tests for loading sample data into DB
Add tests for automatically generated data
This will help us make sure that field mappings and data formats don't change
'b' for *b*undled files
Translators and styles take a long time to install and initialize in
source installations, and they're unnecessary for many tests.
This shaves about 10 seconds off each test run for me on one system (and
that's with some help from filesystem caching).
Don't echo version on Windows, because it hangs Firefox
Also add testing with Firefox Beta (and prior ESR, but commented out for now, since we don't support it and we know it breaks)
Implements the beginnings of unit testing infrastructure using
mocha/chai. The unit tests can be run locally using test/runtests.sh,
although this will need tweaks to run on Windows. They should also run
on commit using Travis-CI.
The unit tests themselves live in test/tests. The index.js file
specifies separate test sets, which can be run individually by calling
test/runtests.sh <testsets>. Right now there is only a single unit
test, but hopefully we'll have more soon...