Skip to content

Commit

Permalink
tests: add tests for optimization mangleExports (#1724)
Browse files Browse the repository at this point in the history
* tests: add tests for optimization mangleExports

* tests: add tests for optimization mangleExports
  • Loading branch information
anshumanv authored Aug 4, 2020
1 parent 42c7d8c commit c8e1dfe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/optimization/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Bokuto")
20 changes: 20 additions & 0 deletions test/optimization/optimization.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');
const { join } = require('path');
const { version } = require('webpack');
const { run } = require('../utils/test-utils');

describe('optimization option in config', () => {
it('should work with mangleExports disabled', () => {
const { stdout, stderr } = run(__dirname, [], false);
// Should throw when webpack is less than 5
if (!version.startsWith('5')) {
expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'");
} else {
// Should apply the provided optimization to the compiler
expect(stdout).toContain('mangleExports: false');
// check that the output file exists
expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeTruthy();
expect(stderr).toBeFalsy();
}
});
});
8 changes: 8 additions & 0 deletions test/optimization/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin');

module.exports = {
plugins: [new WebpackCLITestPlugin()],
optimization: {
mangleExports: false,
},
};

0 comments on commit c8e1dfe

Please sign in to comment.