Skip to content

Commit

Permalink
Run tests w/o source map
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Feb 24, 2015
1 parent 0269f01 commit fd275e9
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 11 deletions.
25 changes: 21 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,31 @@ module.exports = function(grunt) {
'build/all.js': ['src/**/*.js']
},
},
debug: {
files: {
'build/all.js': ['src/**/*.js']
},
options: {
browserifyOptions: {
debug: true // generate a source map
}
}
},
test: {
files: {
'build/tests.js': ['test/**/*-test.js']
},
},
testDebug: {
files: {
'build/tests-debug.js': ['test/**/*-test.js']
},
options: {
browserifyOptions: {
debug: true // generate a source map
}
}
},
options: {
transform: [
[
Expand All @@ -46,9 +66,6 @@ module.exports = function(grunt) {
}
]
],
browserifyOptions: {
debug: true // generate a source map
}
}
},
mocha_phantomjs: {
Expand All @@ -64,7 +81,7 @@ module.exports = function(grunt) {
grunt.registerTask('watchFlow', ['flow:app:start', 'watch:flow']);
grunt.registerTask('watchFlowProd', ['flow:app:start', 'watch:flowProd']);
grunt.registerTask('prod', ['browserify:dist']);
grunt.registerTask('browsertests', ['browserify:test']);
grunt.registerTask('browsertests', ['browserify:test', 'browserify:testDebug']);
grunt.registerTask('test', ['browsertests', 'mocha_phantomjs']);
grunt.registerTask('travis', ['flow', 'test']);
};
4 changes: 2 additions & 2 deletions scripts/post-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ set -x

# Generate LCOV data for the bundled tests using poncho
./node_modules/.bin/poncho \
--reporter lcov test/runner.html \
--reporter lcov test/coverage.html \
| tee build/coverage.lcov

# Convert code coverage data on the bundled test file back to the originals.
./scripts/transform-coverage.js \
build/tests.js \
build/tests-debug.js \
build/coverage.lcov \
| ./node_modules/.bin/coveralls
2 changes: 2 additions & 0 deletions scripts/transform-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var sourcemap = require('source-map');
var fs = require('fs');
var parseDataUri = require('parse-data-uri')
var lcovParse = require('lcov-parse');
var assert = require('assert');

var jsfile = process.argv[2];
var lcovfile = process.argv[3];
Expand Down Expand Up @@ -32,6 +33,7 @@ if (sourcemap_ref_result != null && sourcemap_ref_result.length === 2) {
var SOURCE = 'src/';

lcovParse(lcovfile, function(err, data) {
assert(!err);
// TODO: 0 --> the correct file
var lines = data[0].lines.details;

Expand Down
6 changes: 4 additions & 2 deletions test/FakeXMLHttpRequest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ var FakeXHR = require('./FakeXMLHttpRequest');

describe('FakeXMLHttpRequest', () => {
beforeEach(() => {
console.log('install');
FakeXHR.install();
});
afterEach(() => {
console.log('restore');
FakeXHR.restore();
});

Expand All @@ -22,7 +24,7 @@ describe('FakeXMLHttpRequest', () => {
done();
};
xhr.onerror = function(e) {
throw e;
fail(e);
done();
};
xhr.send();
Expand All @@ -46,7 +48,7 @@ describe('FakeXMLHttpRequest', () => {
done();
};
xhr.onerror = function(e) {
throw e;
fail(e);
done();
};
xhr.send();
Expand Down
4 changes: 2 additions & 2 deletions test/RemoteFile-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ describe('RemoteFile', () => {
FakeXHR.restore();
});

it('should fetch a subset of a file', () => {
it('should fetch a subset of a file', (done) => {
FakeXHR.addResponse('http://example.com/file.txt',
new TextEncoder('utf-8').encode('01234567890').buffer);

var f = new RemoteFile('http://example.com/file.txt');
var promisedData = f.getBytes(10, 20);
var promisedData = f.getBytes(10, 11);

expect(FakeXHR.numRequests).to.equal(1);
// expect(req.requestHeaders.Range).to.equal('bytes=10-29');
Expand Down
30 changes: 30 additions & 0 deletions test/coverage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<html>
<head>
<meta charset="utf-8">
<title>pileup.js Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
</head>
<body>
<div id="mocha"></div>

<!-- Polyfills for PhantomJS -->
<script src="../node_modules/es5-shim/es5-shim.min.js"></script>
<script src="../node_modules/es5-shim/es5-sham.min.js"></script>
<script src="../node_modules/text-encoding/lib/encoding.js"></script>

<!-- Mocha -->
<script src="../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>

<script src="../build/tests.js" data-cover></script>

<script>
mocha.checkLeaks();
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.run();
}
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<!-- Mocha -->
<script src="../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="../build/tests.js" data-cover></script>

<script src="../build/tests-debug.js"></script>

<script>
mocha.checkLeaks();
Expand Down

0 comments on commit fd275e9

Please sign in to comment.