Skip to content

Commit

Permalink
Distinguish between node and browser tests
Browse files Browse the repository at this point in the history
Use "nodespec" and "browserspec" to indicate what test should be run when. Use -spec for both runs
  • Loading branch information
srijken committed Sep 26, 2016
1 parent 8faaaeb commit 573ef06
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
20 changes: 17 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var gulp = require('gulp');
var replace = require('gulp-replace');
var sourcemaps = require('gulp-sourcemaps');
var tsProject = require('tsproject');
var eventStream = require('event-stream');

gulp.task('clean', function () {
var del = require('del');
Expand Down Expand Up @@ -104,7 +105,9 @@ gulp.task('typescript.test', function () {

gulp.task('exceptionless.test.umd', ['typescript.test'], function () {
var umd = require('gulp-wrap-umd');
return gulp.src('dist/temp/src/exceptionless-spec.js')

var wrap = function(filename){
return gulp.src(filename)
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(umd({
exports: 'exports',
Expand All @@ -114,11 +117,16 @@ gulp.task('exceptionless.test.umd', ['typescript.test'], function () {
.pipe(replace('}(this, function(require, exports, module) {', '}(this, function(require, exports, module) {\nif (!exports) {\n\tvar exports = {};\n}\n'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/temp'));
};

return eventStream.merge(
wrap('dist/temp/src/exceptionless-nodespec.js'),
wrap('dist/temp/src/exceptionless-browserspec.js'));
});

gulp.task('test', ['exceptionless.test.umd'], function(done) {
gulp.task('test-node', ['exceptionless.test.umd'], function(done) {
var mocha = require('gulp-mocha');
return gulp.src('dist/temp/exceptionless-spec.js', { read: false })
return gulp.src('dist/temp/exceptionless-nodespec.js', { read: false })
.pipe(mocha({
require: ['source-map-support/register']
}))
Expand All @@ -127,6 +135,12 @@ gulp.task('test', ['exceptionless.test.umd'], function(done) {
});
});

gulp.task('test-browser', function(){

});

gulp.task('test', ['test-node', 'test-browser']);

gulp.task('format', function () {
var exec = require('gulp-exec');
return gulp.src(['src/**/*.ts', '!src/typings/**/*.ts'])
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"del": "2.2.1",
"es5-shim": "4.5.9",
"es6-shim": "0.35.1",
"event-stream": "^3.3.4",
"gulp": "3.9.1",
"gulp-concat": "2.6.0",
"gulp-exec": "2.1.2",
Expand Down
File renamed without changes.
16 changes: 14 additions & 2 deletions src/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,26 @@
"target": "es5"
},
"bundles": {
"exceptionless-spec": {
"exceptionless-nodespec": {
"files": [
"typings/mocha/mocha.d.ts",
"typings/chai/chai.d.ts",
"typings/node/node.d.ts",
"typings/stack-trace/stack-trace.d.ts",

"**/*-spec.ts"
"**/*-spec.ts",
"**/*-browserspec.ts"
]
},
"exceptionless-browserspec": {
"files": [
"typings/mocha/mocha.d.ts",
"typings/chai/chai.d.ts",
"typings/node/node.d.ts",
"typings/stack-trace/stack-trace.d.ts",

"**/*-spec.ts",
"**/*-browserspec.ts"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require.config({
});

require([
'../dist/temp/exceptionless-spec'
'../dist/temp/exceptionless-browserspec'
], function() {

if (typeof mochaPhantomJS !== "undefined") { mochaPhantomJS.run(); }
Expand Down
5 changes: 0 additions & 5 deletions testrunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@
<div id="messages"></div>
<div id="fixtures"></div>
<script src="node_modules/mocha/mocha.js"></script>
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
mocha.setup('bdd');
</script>
<!--<script src="dist/temp/exceptionless-spec.js"></script>-->
<script>
//mocha.run();
</script>
<script data-main="test.config.js" src="node_modules/requirejs/require.js"></script>
</body>
</html>

0 comments on commit 573ef06

Please sign in to comment.