Skip to content

Commit

Permalink
Add Node.js test asserting on the number of sourcemap comments in fin…
Browse files Browse the repository at this point in the history
…al assets
  • Loading branch information
Turbo87 committed Oct 18, 2018
1 parent 8324f80 commit dd36e9a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/node/sourcemap-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var fs = require('fs');

QUnit.module('sourcemap validation', function() {
var assets = ['ember.debug', 'ember.prod', 'ember.min'];

assets.forEach(asset => {
QUnit.test(`${asset} has only a single sourcemaps comment`, function(assert) {
var jsPath = `dist/${asset}.js`;
assert.ok(fs.existsSync(jsPath));

var contents = fs.readFileSync(jsPath, 'utf-8');
var num = count(contents, '//# sourceMappingURL=');
assert.equal(num, 1);
});
});
});

function count(source, find) {
var num = 0;

var i = -1;
while ((i = source.indexOf(find, i + 1)) !== -1) {
num += 1;
}

return num;
}

0 comments on commit dd36e9a

Please sign in to comment.