Automate tests using Headless Chrome + Karma runner

This commit is contained in:
David Humphrey 2018-07-15 13:03:28 -04:00
parent 04f9c57cd8
commit 2ad0d0eb8b
5 changed files with 2254 additions and 8 deletions

View File

@ -1,9 +1,16 @@
sudo: true
language: node_js
node_js:
- "8.11.3"
before_install: npm install -g grunt-cli
- "lts/*"
# Setup headless Chrome support
# https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-the-Chrome-addon-in-the-headless-mode
addons:
chrome: stable
before_install:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
notifications:
email: false
irc: "irc.mozilla.org#filer"
env:
- "FILER_UPSTREAM_URI=\"default\" FILER_UPSTREAM_BRANCH=\"default\" FILER_UPSTREAM_REMOTE_NAME=\"default\""

View File

@ -17,10 +17,13 @@ npm install
You can now run the following `npm` scripts:
* `npm test` will build Filer and the tests in `tests/` and start a web server at http://localhost:1234 where you can run the tests.
* `npm lint` will run `eslint` on the `src` and `tests` directories.
* `npm run lint` will run `eslint` on the `src` and `tests` directories.
* `npm run test:manual` will build the tests, and allow you to run them in a browser manually by loading http://localhost:1234.
* `npm run karma-mocha` will build Filer and the tests, and finally run the tests in a headless Chrome browser.
* `npm test` will run `lint` followed by `karma-chrome`, and is what we do on Travis.
* `npm run build` will bundle two versions of Filer: `dist/filer.js` (unminified) and `dist/filer.min.js` (minified) as well as source map files.
Once you've done some hacking and you'd like to have your work merged, you'll need to
make a pull request. If you're patch includes code, make sure to check that all the
unit tests pass, including any new tests you wrote. Finally, make sure you add yourself

18
karma.conf.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = function(config) {
config.set({
browsers: ['ChromeHeadless'],
singleRun: true,
basePath: '',
files: ['tests/dist/index.js'],
frameworks: ['mocha', 'chai'],
reporters: ['mocha'],
client: {
mocha: {
ui: 'bdd',
timeout: 5000,
slow: 250
}
}
});
};

2209
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,13 @@
"license": "BSD-2-Clause",
"scripts": {
"lint": "eslint src tests",
"test": "parcel tests/index.html --out-dir tests/dist",
"test:manual": "parcel tests/index.html --out-dir tests/dist",
"pretest": "npm run lint",
"test": "npm run travis",
"prebuild": "parcel build --global Filer src/index.js --no-minify --out-file filer.js",
"build": "parcel build --global Filer src/index.js --out-file filer.min.js --detailed-report"
"build": "parcel build --global Filer src/index.js --out-file filer.min.js --detailed-report",
"prekarma-mocha": "parcel build tests/index.js --out-dir tests/dist",
"karma-mocha": "karma start karma.conf.js"
},
"repository": {
"type": "git",
@ -33,6 +37,11 @@
"devDependencies": {
"chai": "^4.1.2",
"eslint": "^5.0.1",
"karma": "^2.0.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^5.2.0",
"parcel-bundler": "^1.9.6"
},