First server tests
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
||||
node_modules
|
||||
bower_components
|
||||
.vagrant
|
||||
results/*
|
||||
results/*
|
||||
coverage
|
||||
+46
-1
@@ -12,12 +12,57 @@ module.exports = function(grunt) {
|
||||
'app/public/scripts/*.js',
|
||||
'phantomas_custom/**/*.js'
|
||||
]
|
||||
},
|
||||
clean: {
|
||||
coverage: {
|
||||
src: ['coverage/']
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
coverage: {
|
||||
src: ['test/**'],
|
||||
dest: 'coverage/'
|
||||
}
|
||||
},
|
||||
blanket: {
|
||||
coverage: {
|
||||
src: ['app/'],
|
||||
dest: 'coverage/app/'
|
||||
}
|
||||
},
|
||||
mochaTest: {
|
||||
test: {
|
||||
options: {
|
||||
reporter: 'spec',
|
||||
},
|
||||
src: ['coverage/test/server/*.js']
|
||||
},
|
||||
coverage: {
|
||||
options: {
|
||||
reporter: 'html-cov',
|
||||
// use the quiet flag to suppress the mocha console output
|
||||
quiet: true,
|
||||
// specify a destination file to capture the mocha
|
||||
// output (the quiet option does not suppress this)
|
||||
captureFile: 'coverage/coverage.html'
|
||||
},
|
||||
src: ['coverage/test/server/*.js']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
|
||||
|
||||
|
||||
grunt.registerTask('hint', ['jshint']);
|
||||
grunt.registerTask('hint', [
|
||||
'jshint'
|
||||
]);
|
||||
|
||||
grunt.registerTask('test', [
|
||||
'clean:coverage',
|
||||
'blanket',
|
||||
'copy:coverage',
|
||||
'mochaTest'
|
||||
]);
|
||||
|
||||
};
|
||||
+7
-1
@@ -16,7 +16,13 @@
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-contrib-jshint": "^0.10.0",
|
||||
"matchdep": "^0.3.0"
|
||||
"matchdep": "^0.3.0",
|
||||
"grunt-mocha-test": "^0.11.0",
|
||||
"grunt-contrib-clean": "^0.6.0",
|
||||
"grunt-contrib-copy": "^0.5.0",
|
||||
"grunt-blanket": "0.0.8",
|
||||
"chai": "^1.9.1",
|
||||
"mocha": "^1.21.4"
|
||||
},
|
||||
"scripts": {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
var path = require('path');
|
||||
var srcDir = path.join(__dirname, '..', 'server');
|
||||
|
||||
require('blanket')({
|
||||
// Only files that match the pattern will be instrumented
|
||||
pattern: srcDir
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
var should = require('chai').should();
|
||||
var phantomasWrapper = require('../../app/lib/phantomasWrapper.js');
|
||||
|
||||
describe('phantomasWrapper', function() {
|
||||
|
||||
it('should have a method execute', function() {
|
||||
phantomasWrapper.should.have.property('execute').that.is.a('function');
|
||||
});
|
||||
|
||||
it('should execute', function(done) {
|
||||
var url = 'http://www.google.fr';
|
||||
|
||||
this.timeout(15000);
|
||||
phantomasWrapper.execute({
|
||||
url: url,
|
||||
testId: '123abc',
|
||||
options:{
|
||||
|
||||
}
|
||||
}, function(err, json, results) {
|
||||
should.not.exist(err);
|
||||
|
||||
json.should.be.an('object');
|
||||
json.should.have.a.property('generator').that.contains('phantomas');
|
||||
json.should.have.a.property('url').that.equals(url);
|
||||
json.should.have.a.property('metrics').that.is.an('object').not.empty();
|
||||
json.should.have.a.property('offenders').that.is.an('object').not.empty();
|
||||
json.offenders.should.have.a.property('javascriptExecutionTree').that.is.a('string');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail with error 254', function(done) {
|
||||
var url = 'http://www.not.existing';
|
||||
|
||||
this.timeout(15000);
|
||||
phantomasWrapper.execute({
|
||||
url: url,
|
||||
testId: '123abc',
|
||||
options:{
|
||||
|
||||
}
|
||||
}, function(err, json, results) {
|
||||
should.exist(err);
|
||||
err.should.equal(254);
|
||||
should.not.exist(json);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
var should = require('chai').should();
|
||||
var testQueue = require('../../app/lib/testQueue.js');
|
||||
|
||||
describe('testQueue', function() {
|
||||
|
||||
it('should have a method push', function() {
|
||||
testQueue.should.have.property('push').that.is.a('function');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user