2018-12-29 07:21:24 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const path = require("path");
|
2019-06-11 19:09:42 +08:00
|
|
|
const fs = require("graceful-fs");
|
2018-12-29 07:21:24 +08:00
|
|
|
const webpack = require("../");
|
|
|
|
const rimraf = require("rimraf");
|
|
|
|
|
2020-03-29 06:10:15 +08:00
|
|
|
describe("Profiling Plugin", function () {
|
2020-09-01 15:12:53 +08:00
|
|
|
jest.setTimeout(30000);
|
2019-01-02 17:34:41 +08:00
|
|
|
|
2018-12-29 07:21:24 +08:00
|
|
|
it("should handle output path with folder creation", done => {
|
2019-06-11 19:09:42 +08:00
|
|
|
const outputPath = path.join(__dirname, "js/profilingPath");
|
|
|
|
const finalPath = path.join(outputPath, "events.json");
|
2018-12-29 07:21:24 +08:00
|
|
|
rimraf(outputPath, () => {
|
|
|
|
const compiler = webpack({
|
2019-06-11 19:09:42 +08:00
|
|
|
context: __dirname,
|
2018-12-29 07:21:24 +08:00
|
|
|
entry: "./fixtures/a.js",
|
2019-06-11 19:09:42 +08:00
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, "js/profilingOut")
|
|
|
|
},
|
2018-12-29 07:21:24 +08:00
|
|
|
plugins: [
|
|
|
|
new webpack.debug.ProfilingPlugin({
|
|
|
|
outputPath: finalPath
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
compiler.run(err => {
|
|
|
|
if (err) return done(err);
|
|
|
|
if (!fs.existsSync(outputPath))
|
|
|
|
return done(new Error("Folder should be created."));
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|