Merge pull request #121 from Jabher/karma_tests

bringing karma for browser testing
Esse commit está contido em:
Juan Cazala
2016-08-03 11:26:45 -03:00
commit de GitHub
7 arquivos alterados com 48 adições e 5 exclusões
+1
Ver Arquivo
@@ -1,4 +1,5 @@
language: node_js
script: "npm run test:travis"
node_js:
# always latest release
- "node"
+25
Ver Arquivo
@@ -0,0 +1,25 @@
// Karma configuration
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha'],
files: [
'dist/synaptic.js',
'test/[^_]*.js'
],
exclude: [
],
preprocessors: {
'test/*.js': ['webpack'],
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
singleRun: false,
concurrency: Infinity,
browserNoActivityTimeout: 60000,
})
}
+15 -2
Ver Arquivo
@@ -4,7 +4,14 @@
"description": "architecture-free neural network library",
"main": "./src/synaptic",
"scripts": {
"test": "mocha test",
"test": "npm run test:src",
"test:src": "mocha test --require src/synaptic.js ./test",
"test:dist": "npm run build && npm run test:mocha:dist && npm run test:karma:browsers",
"test:mocha:src": "mocha test --require src/synaptic.js ./test",
"test:mocha:dist": "mocha test --require dist/synaptic.js ./test",
"test:karma:browsers": "karma start --single-run --browsers Chrome,Firefox,SafariPrivate",
"test:karma:phantomjs": "karma start --single-run --browsers PhantomJS",
"test:travis": "npm run test:mocha:src && npm run build && npm run test:mocha:dist",
"build": "webpack --config webpack.config.js"
},
"prepush": [
@@ -14,9 +21,15 @@
"devDependencies": {
"chai": "^3.5.0",
"chai-stats": "^0.3.0",
"karma": "^1.1.2",
"karma-chrome-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.1",
"karma-safari-launcher": "^1.0.0",
"karma-webpack": "^1.7.0",
"mocha": "^2.2.4",
"pre-push": "^0.1.1",
"random-js": "^1.0.8",
"webpack": "^1.13.1"
},
"repository": {
+1
Ver Arquivo
@@ -0,0 +1 @@
global.synaptic = require('../dist/synaptic');
+1
Ver Arquivo
@@ -0,0 +1 @@
global.synaptic = require('../src/synaptic');
+1
Ver Arquivo
@@ -0,0 +1 @@
[^_]*.js
+4 -3
Ver Arquivo
@@ -3,8 +3,6 @@ var chai = require('chai');
chai.use(require('chai-stats'));
var assert = chai.assert;
var synaptic = require('../src/synaptic');
var Perceptron = synaptic.Architect.Perceptron;
var LSTM = synaptic.Architect.LSTM;
var Layer = synaptic.Layer;
@@ -425,6 +423,7 @@ describe("Optimized and Unoptimized Networks Equivalency", function () {
it('should produce the same output for both networks', function () {
this.timeout(30000);
for (var i = 0; i < 1000; i++) {
var input = generateRandomArray(2);
var target = generateRandomArray(1);
@@ -434,7 +433,7 @@ describe("Optimized and Unoptimized Networks Equivalency", function () {
unoptimized.propagate(learningRate, target);
}
var mse = calculateMse(optimized.activate(input), unoptimized.activate(input));
assert.isAtMost(mse, 1e-10, 'output should be same for both networks after ' + i + ' iterations');
assert.isAtMost(mse, 1e-9, 'output should be same for both networks after ' + i + ' iterations');
});
});
@@ -447,6 +446,7 @@ describe("toJSON/fromJSON Networks Equivalency", function () {
});
it('should produce the same output for both networks', function () {
this.timeout(30000);
for (var i = 0; i < 1000; i++) {
var input = generateRandomArray(10);
var output1 = original.activate(input);
@@ -473,6 +473,7 @@ describe("Cloned Networks Equivalency", function () {
});
it('should produce the same output for both networks', function () {
this.timeout(30000);
for (var i = 0; i < 1000; i++) {
var input = generateRandomArray(10);
var output1 = original.activate(input);