diff options
-rw-r--r-- | README | 20 | ||||
-rw-r--r-- | test.js | 27 |
2 files changed, 47 insertions, 0 deletions
@@ -29,6 +29,7 @@ To debug this add-on on IceCat and other Firefox derivatives, browse to the spec LibreJS should work with other WebExtensions-compliant browsers; but currently, none of them meet the freedom standards of GNU, so no help will be provided for their usage. + TEST: An automated test suite runs automatically in its own tab whenever the extension @@ -36,6 +37,25 @@ is loaded as a "temporary add-on" from about:debugging. Otherwise (if included in the xpi, see BUILD above) it can be launched from the UI by clicking the [Automated self test...] button. +To launch the test in command line, ensure the extension has been +built with automated test suite. Then install selenium-webdriver and +geckodriver, and ensure the latter is in $PATH: + + $ npm install selenium-webdriver + $ npm install geckodriver + $ export PATH=$PATH:./node_modules/.bin + +Now you can invoke the test with + + $ node ./test.js + +which will print out a summary of test results. + +Optionally you can also test with a chosen seed + + $ node ./test.js 12345 + + CONTACT: Development mailing list: bug-librejs@gnu.org @@ -0,0 +1,27 @@ +/* A node script that runs tests in a headless browser. */ + +(function libreJSTest() { + const webdriver = require('selenium-webdriver'); + const firefox = require('selenium-webdriver/firefox'); + new webdriver.Builder().forBrowser('firefox') + .setFirefoxOptions(new firefox.Options() + // Uncomment this line to test using icecat +// .setBinary("/usr/bin/icecat") + .headless()).build() + .then(driver => + driver.installAddon("./librejs.xpi", /*isTemporary=*/true) + .then(driver.get("about:debugging#/runtime/this-firefox")) + .then(_ => driver.findElements(webdriver.By.css('.fieldpair dd'))) + .then(es => es[2].getText()) + .then(uuid => + driver.get('moz-extension://' + + uuid + '/test/SpecRunner.html' + + (process.argv[2] ? '?seed=' + process.argv[2] : '') )) + .then(_ => driver.wait(_ => + driver.findElement(webdriver.By.css('.jasmine-alert')) + .then(e => e.getText()), 10000)) + .then(_ => driver.findElement(webdriver.By.css('.jasmine-alert'))) + .then(e => e.getText()) + .then(console.log) + .then(_ => driver.quit())); +})(); |