Automate tests using Headless Chrome + Karma runner
This commit is contained in:
parent
04f9c57cd8
commit
2ad0d0eb8b
15
.travis.yml
15
.travis.yml
|
@ -1,9 +1,16 @@
|
||||||
|
sudo: true
|
||||||
|
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "8.11.3"
|
- "lts/*"
|
||||||
before_install: npm install -g grunt-cli
|
|
||||||
|
# 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:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
irc: "irc.mozilla.org#filer"
|
irc: "irc.mozilla.org#filer"
|
||||||
env:
|
|
||||||
- "FILER_UPSTREAM_URI=\"default\" FILER_UPSTREAM_BRANCH=\"default\" FILER_UPSTREAM_REMOTE_NAME=\"default\""
|
|
||||||
|
|
|
@ -17,10 +17,13 @@ npm install
|
||||||
|
|
||||||
You can now run the following `npm` scripts:
|
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 run lint` will run `eslint` on the `src` and `tests` directories.
|
||||||
* `npm 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.
|
* `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
|
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
|
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
|
unit tests pass, including any new tests you wrote. Finally, make sure you add yourself
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
|
@ -18,9 +18,13 @@
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint src tests",
|
"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",
|
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -33,6 +37,11 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"eslint": "^5.0.1",
|
"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",
|
"mocha": "^5.2.0",
|
||||||
"parcel-bundler": "^1.9.6"
|
"parcel-bundler": "^1.9.6"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue