Add webpack, karma, coverage tests.

This commit is contained in:
Marina Samuel 2017-02-09 13:58:22 -05:00
Родитель ec4796eea7
Коммит 2fcdeda0a4
6 изменённых файлов: 65 добавлений и 10 удалений

2
.eslintignore Normal file
Просмотреть файл

@ -0,0 +1,2 @@
coverage/
dist/

4
.gitignore поставляемый
Просмотреть файл

@ -1,2 +1,4 @@
dist
node_modules
.DS_Store
.DS_Store
coverage

Просмотреть файл

@ -1,4 +1,16 @@
language: node_js
node_js:
- "7.2.0"
- '6'
addons:
firefox: latest
before_install:
- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile
--background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 -extension RANDR
- sleep 3
install:
- npm config set spin false
- npm install
script:
- npm run travis

Просмотреть файл

@ -2,19 +2,21 @@
"name": "ping-centre",
"version": "1.0.0",
"description": "A client for easily collecting events and metrics.",
"main": "ping-centre.js",
"main": "src/ping-centre.js",
"license": "MPL-2.0",
"scripts": {
"test": "npm-run-all test:*",
"test:code": "make test",
"test:lint": "eslint ."
"bundle": "webpack",
"test": "npm run bundle && npm run test:node && npm run test:browser && npm run test:lint",
"test:node": "istanbul cover _mocha -- --recursive",
"test:browser": "karma start test/karma.conf.js",
"travis": "npm test && cat ./coverage/lcov.info | coveralls",
"test:lint": "eslint . --ext .js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mozilla/ping-centre.git"
},
"author": "Marina Samuel <msamuel@mozilla.com>",
"license": "MPL-2.0",
"bugs": {
"url": "https://github.com/mozilla/ping-centre/issues"
},
@ -22,14 +24,21 @@
"dependencies": {
"isomorphic-fetch": "^2.2.1",
"joi-browser": "^10.0.6",
"uuid": "^3.0.0"
"uuid": "^3.0.1"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"coveralls": "^2.11.16",
"eslint": "^3.12.2",
"fetch-mock": "^5.5.0",
"istanbul": "^0.4.5",
"karma": "^1.4.1",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.2",
"karma-webpack": "^2.0.2",
"mocha": "^3.1.2",
"npm-run-all": "^3.1.1"
"webpack": "^2.2.1"
}
}

17
test/karma.conf.js Normal file
Просмотреть файл

@ -0,0 +1,17 @@
"use strict";
module.exports = function(config) {
config.set({
singleRun: true,
browsers: ["Firefox"],
frameworks: ["mocha"],
files: ["./unit/**/*.js"],
reporters: ["mocha"],
// Applies webpack to the test files, so they can use "require"
preprocessors: {"./unit/**/*.js": ["webpack"]},
// This hides some overly verbose output from the console
webpackMiddleware: {noInfo: true}
});
};

13
webpack.config.js Normal file
Просмотреть файл

@ -0,0 +1,13 @@
"use strict";
module.exports = {
entry: "./src/ping-centre.js",
output: {
path: "./dist",
filename: "ping-centre.min.js",
// exports entry file to a global variable
libraryTarget: "var",
// name of the global variable
library: "PingCentre"
},
};