UNPKG

@frontity/core

Version:

The core package of the Frontity framework.

80 lines (70 loc) 1.88 kB
import * as hash from "hash-it"; import * as path from "path"; import getWebpack from ".."; jest.mock("path"); const mockedPath = path as jest.Mocked<typeof path>; mockedPath.resolve.mockImplementation((_, ...dirs) => dirs.join("/")); jest.mock("hash-it"); const mockedHash = hash as jest.Mocked<typeof hash>; mockedHash.default.mockReturnValue("123"); const babel = { development: { es5: { presets: ["es5-development"], plugins: [] }, module: { presets: ["module-development"], plugins: [] }, server: { presets: ["server-development"], plugins: [] }, }, production: { es5: { presets: ["es5-production"], plugins: [] }, module: { presets: ["module-production"], plugins: [] }, server: { presets: ["server-production"], plugins: [] }, }, }; const frontity = { outDir: "build", }; const entryPoints = [ { name: "server", path: "./build/bundling/entry-points/server.js", }, { name: "site-1", path: "./build/bundling/entry-points/site-1/client.js", }, { name: "site-2", path: "./build/bundling/entry-points/site-1/client.js", }, ]; test("Webpack returns for development", () => { expect( getWebpack({ mode: "development", babel: babel["development"], frontity, entryPoints, }) ).toMatchSnapshot(); }); test("Webpack returns for production", () => { expect( getWebpack({ mode: "production", babel: babel["production"], frontity, entryPoints, }) ).toMatchSnapshot(); }); test("Webpack includes the Bundle Analyzer plugin if specified", () => { const { es5, module, server } = getWebpack({ mode: "production", babel: babel["production"], frontity, entryPoints, analyze: true, }); expect(es5.plugins).toMatchSnapshot(); expect(module.plugins).toMatchSnapshot(); expect(server.plugins).toMatchSnapshot(); });