Fauxton has both unit tests, implemented with Jest, and end-to-end tests using Nightwatch against Selenium.
To run all tests:
npm run test
You can run only specific tests by providing a pattern or filename.
E.g.: to run tests in the filename.test.js
file:
npm run test -- filename.test.js
E.g.: to run tests under the addons/cors
path:
npm run test -- addons/cors
Nightwatch tests require that you have Chrome installed. If you prefer to use another browser, update test/nightwatch_tests/nightwatch.json.underscore
and install the appropriate driver - see Nightwatch documentation for more details.
The tests also require a CouchDB server (see step 2).
- Define the version of CouchDB to test against
COUCHDB_IMAGE=couchdb:3
NIGHTWATCH_SKIPTAGS="search,nonpartitioned,couchdb-v2-only"
-- OR --
COUCHDB_IMAGE=couchdb:2.3.1
NIGHTWATCH_SKIPTAGS="search,partitioned"
- Start a CouchDB instance
npm run docker:up
(run npm run docker:logs
to see when the CouchDB instance is ready to go)
3. Start Fauxton
grunt debugDev && DIST=./dist/debug ./bin/fauxton
- Run the tests
grunt nightwatch
Or to run only one file:
grunt nightwatch --file=filename
View the package.json scripts
section for other useful Docker commands.
If you need to omit particular tests from running you can add a testBlacklist
option to the nightwatch section of
your settings.json file. It should define an object of the following form:
// ...
"nightwatch": {
// ...
"testBlacklist": {
"documents": ["*"],
"databases": [
"checkDatabaseTooltip.js",
"createsDatabase.js"
]
}
}
// ...
The properties (documents
, databases
) map to a particular addon folder name (see app/addons
). The values
should be an array of tests that you don't want to run. *
will flag all tests from being ran, otherwise you
just enter the names of the files to omit.
Each test run generates a new database. Sometimes these databases will not be removed. You can run npm run remove-test-dbs
to clean up any left over databases.