add ability to run tests in headless mode, generally clean up all the npm scripts

This commit is contained in:
Peter Snyder 2017-10-27 19:54:44 -05:00
parent 8a45bc6ff6
commit d8f6f653ba
3 changed files with 56 additions and 41 deletions

View file

@ -110,7 +110,10 @@ cp test.config.example.js test.config.js
vim test.config.js
# Run the test suite
npm run test
npm test
# Or, if you want to watch the tests run...
npm run test:watch
```

View file

@ -24,11 +24,16 @@
"clean": "rm -Rf dist/",
"bundle": "gulp && web-ext -s add-on -a dist build --overwrite-dest",
"firefox": "web-ext -s add-on run",
"test:lint": "node_modules/eslint/bin/eslint.js .",
"test:lint:fix": "node_modules/eslint/bin/eslint.js --fix .",
"test:func": "npm run clean; npm run bundle && ln -s `ls dist/` dist/webapi_manager.zip && node_modules/mocha/bin/mocha test/functional/*.js",
"test:func:block": "npm run clean; npm run bundle && ln -s `ls dist/` dist/webapi_manager.zip && node_modules/mocha/bin/mocha test/functional/block.js",
"test": "npm run test:lint && npm run test:func"
"lint": "node_modules/eslint/bin/eslint.js .",
"lint:fix": "node_modules/eslint/bin/eslint.js --fix .",
"test": "npm run clean; npm run bundle && ln -s `ls dist/` dist/webapi_manager.zip && node_modules/mocha/bin/mocha test/functional/*.js",
"test:watch": "npm test --watch"
},
"pre-push": {
"run": [
"lint",
"test"
]
},
"devDependencies": {
"assert": "^1.4.1",

View file

@ -80,8 +80,15 @@ module.exports.promiseSetBlockingRules = function (driver, standardsToBlock) {
module.exports.promiseGetDriver = function () {
const binary = new firefox.Binary();
if (process.argv.indexOf("--watch") === -1) {
binary.addArguments("--headless");
}
const driver = new webdriver.Builder()
.forBrowser("firefox")
.setFirefoxOptions(new firefox.Options().setBinary(binary))
.build();
driver.setContext(Context.CHROME);