Skip to content

Browsertesting #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 27, 2016
23 changes: 20 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var gulp = require('gulp');
var replace = require('gulp-replace');
var sourcemaps = require('gulp-sourcemaps');
var tsProject = require('tsproject');
var eventStream = require('event-stream');
var mochaPhantomJS = require('gulp-mocha-phantomjs');

gulp.task('clean', function () {
var del = require('del');
Expand Down Expand Up @@ -104,7 +106,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 +118,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 +136,14 @@ gulp.task('test', ['exceptionless.test.umd'], function(done) {
});
});

gulp.task('test-browser', ['exceptionless.test.umd'], function(){
return gulp
.src('testrunner.html')
.pipe(mochaPhantomJS());
});

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
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@
"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",
"gulp-mocha": "2.2.0",
"gulp-mocha-phantomjs": "^0.12.0",
"gulp-replace": "0.5.4",
"gulp-sourcemaps": "1.6.0",
"gulp-tslint": "6.0.1",
"gulp-uglify": "1.5.4",
"gulp-wrap-umd": "0.2.1",
"mock-fs": "3.11.0",
"path": "^0.12.7",
"requirejs": "^2.3.2",
"rewire": "^2.5.2",
"rimraf": "2.5.3",
"source-map-support": "0.4.2",
"mock-fs": "3.11.0",
"systemjs": "^0.19.39",
"tracekit": "0.4.3",
"tslint": "3.13.0",
"tsproject": "1.2.1",
Expand Down
23 changes: 23 additions & 0 deletions src/storage/Storage-nodespec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { NodeFileStorage } from './NodeFileStorage';

import { describeStorage } from './Storage-spec';

import * as mockFs from 'mock-fs';

let mockedFs;

let nodeFileStorageFactory = (maxItems?) => {
return new NodeFileStorage('test', './fileStorage', 'ex-', maxItems, mockedFs);
};

let nodeFileStorageInitializer = () => {
mockedFs = mockFs.fs({
'fileStorage': {}
});
};

describeStorage('NodeFileStorage',
nodeFileStorageFactory,
nodeFileStorageInitializer,
true
);
22 changes: 1 addition & 21 deletions src/storage/Storage-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,14 @@ import { IStorage } from './IStorage';
import { IStorageItem } from './IStorageItem';

import { InMemoryStorage } from './InMemoryStorage';
import { NodeFileStorage } from './NodeFileStorage';

import { expect } from 'chai';
import * as mockFs from 'mock-fs';

let mockedFs;

let nodeFileStorageFactory = (maxItems?) => {
return new NodeFileStorage('test', './fileStorage', 'ex-', maxItems, mockedFs);
};

let nodeFileStorageInitializer = () => {
mockedFs = mockFs.fs({
'fileStorage': {}
});
};

describeStorage('NodeFileStorage',
nodeFileStorageFactory,
nodeFileStorageInitializer,
true
);

describeStorage('InMemoryStorage', (maxItems = 250) => {
return new InMemoryStorage(maxItems);
});

function describeStorage(name: string,
export function describeStorage(name: string,
storageFactory: (maxItems?: number) => IStorage,
beforeEachCallback?: () => void,
recreateStorage: boolean = false) {
Expand Down
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",
"**/*-nodespec.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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should leave node.d.ts and stack-trace.d.ts out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done..


"**/*-spec.ts",
"**/*-browserspec.ts"
]
}
}
Expand Down
19 changes: 19 additions & 0 deletions test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require.config({
baseUrl: 'node_modules',
paths: {
chai: 'chai/chai',
TraceKit: 'tracekit/tracekit'
}
});

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

if (typeof mochaPhantomJS !== "undefined") { mochaPhantomJS.run(); }
else {

console.log('running mocha');
mocha.run();
}
});
23 changes: 23 additions & 0 deletions testrunner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>

<head>
<title>Mocha</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="node_modules/mocha/mocha.css" />
</head>

<body>
<div id="mocha">
<p><a href="?">Index</a></p>
</div>
<div id="messages"></div>
<div id="fixtures"></div>
<script src="node_modules/mocha/mocha.js"></script>
<script>
mocha.setup('bdd');
</script>
<script data-main="test.config.js" src="node_modules/requirejs/require.js"></script>
</body>
</html>