UNPKG

html-render-webpack-plugin

Version:

webpack plugin for rendering static HTML in a multi-config webpack build

30 lines (24 loc) 942 B
const { createInMemoryFileSystem } = require("../../utils/memory-fs"); const webpack = require("webpack"); const config = require("./webpack.config"); function getCurrentMemoryUsageInMB() { return Math.round((process.memoryUsage().heapUsed / 1024 / 1024) * 100) / 100; } describe("Render multiple times without increasing heap memory", () => { it("should not leak memory when memoizing webpackStats", async (done) => { jest.setTimeout(20 * 1000); const compiler = webpack(config); const initialMemoryUsage = getCurrentMemoryUsageInMB(); const memoryFs = createInMemoryFileSystem(); compiler.outputFileSystem = memoryFs; compiler.run((error, stats) => { if (error) { throw error; } expect(stats.hasErrors()).toBe(false); const afterMemoryUsage = getCurrentMemoryUsageInMB(); expect(afterMemoryUsage - initialMemoryUsage).toBeLessThan(150); done(); }); }); });