Use headless chrome to run tests

This commit is contained in:
Martin Kleinschrodt 2017-06-18 16:18:28 +02:00
parent f426af4a30
commit eafe5724ae
8 changed files with 759 additions and 72 deletions

View File

@ -10,13 +10,13 @@ const st = require("st");
// Deploy a minified/built version of the app to a given destination folder
gulp.task("build", () => {
let promises = [];
const { mac, win, linux, electron, chrome, release } = argv;
const { mac, win, linux, chrome, release } = argv;
if (chrome) {
promises.push(buildChrome());
}
if (electron || mac || win || linux) {
if (mac || win || linux) {
promises.push(buildElectron({ mac, win, linux, release }));
}

14
karma.conf.js Normal file
View File

@ -0,0 +1,14 @@
module.exports = function(config) {
config.set({
frameworks: ["mocha", "chai"],
files: ["test/tests.js"],
reporters: ["progress"],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ["ChromeHeadless"],
autoWatch: false,
// singleRun: false, // Karma captures browsers, runs the tests and exits
concurrency: Infinity
});
};

734
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
"type": "git",
"url": "git+https://github.com/maklesoft/padlock.git"
},
"main": "main.js",
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/core-js": "^0.9.35",
@ -27,6 +28,10 @@
"fs-extra": "^1.0.0",
"gulp": "^3.9.1",
"gulp-insert-lines": "0.0.4",
"karma": "^1.7.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.1.1",
"karma-mocha": "^1.3.0",
"mocha": "^3.4.2",
"papaparse": "^4.1.2",
"polymer-bundler": "^2.0.0-pre.6",
@ -40,15 +45,15 @@
"yargs": "^4.8.1"
},
"dependencies": {
"electron-updater": "^2.1.2"
"electron-updater": "^2.1.2",
"yargs": "^4.8.1"
},
"scripts": {
"bower-install": "pushd app && bower install && popd app",
"compile": "gulp compile --silent",
"debug": "gulp --silent --watch",
"lint": "eslint app/**/*.{js,html}",
"test": "npm run lint && npm run compile && mocha --ui tdd",
"start": "gulp build --electron --silent && electron dist/electron",
"test": "karma start --single-run --browsers ChromeHeadless karma.conf.js",
"app": "electron . --noupdate",
"postinstall": "npm run bower-install && npm run compile"
}
}

View File

@ -9,12 +9,6 @@
<body>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script>
mocha.setup("tdd");
</script>
<script src="./tests.js"></script>
<script>
mocha.run();
</script>
</body>
</html>

View File

@ -1,6 +1,12 @@
declare var mocha: any;
mocha.setup("tdd");
import "./util.ts";
import "./crypto.ts";
import "./source.ts";
import "./data.ts";
import "./import.ts";
import "./export.ts";
mocha.run();

View File

@ -1,50 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Runner</title>
<link rel="stylesheet" href="qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="qunit.js"></script>
<!-- Function.prototype.bind polyfill -->
<script src="bind.js"></script>
<!-- Source code, symlinked into the test dir -->
<script src="../app/bower_components/sjcl/sjcl.js"></script>
<script src="../app/bower_components/zxcvbn/lib/zxcvbn.js"></script>
<script src="../app/bower_components/papaparse/papaparse.js"></script>
<script>padlock={};</script>
<script src="../app/src/util.js"></script>
<script src="../app/src/rand.js"></script>
<script src="../app/src/crypto.js"></script>
<script src="../app/src/import.js"></script>
<script src="../app/src/platform.js"></script>
<script src="../app/src/Source.js"></script>
<script src="../app/src/LocalStorageSource.js"></script>
<script src="../app/src/ChromeStorageSource.js"></script>
<script>
padlock.LocalSource = padlock.platform.isChromeApp() ?
padlock.ChromeStorageSource : padlock.LocalStorageSource;
</script>
<script src="../app/src/CloudSource.js"></script>
<script src="../app/src/Store.js"></script>
<script src="../app/src/Collection.js"></script>
<script src="../app/src/Settings.js"></script>
<!-- Fixtures -->
<script src="secustore-backup.js"></script>
<!-- Tests -->
<script src="util.js"></script>
<script src="crypto.js"></script>
<script src="rand.js"></script>
<!-- <script src="import.js"></script> -->
<script src="Collection.js"></script>
<script src="Settings.js"></script>
</body>
</html>

View File

@ -49,8 +49,8 @@ suite("util", function() {
for (var char in count) {
var dev = count[char] / avg - 1;
assert(
Math.abs(dev) < 0.05,
"Deviation of each char count from expected average should be less than 5%; " +
Math.abs(dev) < 0.1,
"Deviation of each char count from expected average should be less than 10%; " +
"Got " + dev + " for " + char
);
}