Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgarlis committed Jun 10, 2022
1 parent e6a2f43 commit 7401f2d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/sourcemaps/samples/sourcemap-base-url/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');

module.exports = {
description: 'adds a sourcemap base url',
options: {
output: {
sourcemapBaseUrl: 'https://example.com'
}
},
test: (code, map, profile) => {
assert.equal(map.file, `bundle.${profile.format}.js`);
const bundlePath = path.join(__dirname, `_actual/bundle.${profile.format}.js`);
const bundledCode = fs.readFileSync(bundlePath, { encoding: 'utf8', flag: 'r' });
const sourceMappingURL = bundledCode.split('\n').slice(-2)[0];
assert.equal(
sourceMappingURL,
`//# sourceMappingURL=https://example.com/bundle.${profile.format}.js.map`
);
}
};
1 change: 1 addition & 0 deletions test/sourcemaps/samples/sourcemap-base-url/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log( 42 );

0 comments on commit 7401f2d

Please sign in to comment.