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

(cherry picked from commit dd36e9a)
  • Loading branch information
Turbo87 authored and rwjblue committed Oct 29, 2018
1 parent b10b27d commit 27ca580
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/node/sourcemap-test.js
@@ -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 27ca580

Please sign in to comment.