Sha256: 5298a3490c410345c0d3e54b75a1ac9759563ef3b71dcf7965bb24da1bf33e99

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

const { resolve } = require("path")
const { chdirTestApp, resetEnv } = require("../helpers")

const rootPath = process.cwd()
chdirTestApp()

jest.mock("../../package/utils/helpers", () => {
  const original = jest.requireActual("../../package/utils/helpers")
  const moduleExists = () => false
  return {
    ...original,
    moduleExists
  }
})

describe("Development environment", () => {
  beforeEach(() => jest.resetModules() && resetEnv())
  afterAll(() => process.chdir(rootPath))

  describe("generateWebpackConfig", () => {
    beforeEach(() => jest.resetModules())

    test("should use development config and environment including devServer if WEBPACK_SERVE", () => {
      process.env.RAILS_ENV = "development"
      process.env.NODE_ENV = "development"
      process.env.WEBPACK_SERVE = "true"
      const { generateWebpackConfig } = require("../../package/index")

      const webpackConfig = generateWebpackConfig()

      expect(webpackConfig.output.path).toStrictEqual(
        resolve("public", "packs")
      )
      expect(webpackConfig.output.publicPath).toBe("/packs/")
    })

    test("should use development config and environment if WEBPACK_SERVE", () => {
      process.env.RAILS_ENV = "development"
      process.env.NODE_ENV = "development"
      process.env.WEBPACK_SERVE = undefined
      const { generateWebpackConfig } = require("../../package/index")

      const webpackConfig = generateWebpackConfig()

      expect(webpackConfig.output.path).toStrictEqual(
        resolve("public", "packs")
      )
      expect(webpackConfig.output.publicPath).toBe("/packs/")
      expect(webpackConfig.devServer).toBeUndefined()
    })
  })
})

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shakapacker-8.1.0 test/package/development.test.js
shakapacker-8.0.2 test/package/development.test.js