Sha256: 3dc9ce5993ac9e380c77f633ee7d3d74c86d2e7345c3a61937fc38594649d1f0

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

const { resolve } = require("path")
const { chdirTestApp } = 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("Custom environment", () => {
  afterAll(() => process.chdir(rootPath))

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

    test("should use staging config and default production environment", () => {
      process.env.RAILS_ENV = "staging"
      delete process.env.NODE_ENV

      const { generateWebpackConfig } = require("../../package/index")

      const webpackConfig = generateWebpackConfig()

      expect(webpackConfig.output.path).toStrictEqual(
        resolve("public", "packs-staging")
      )
      expect(webpackConfig.output.publicPath).toBe("/packs-staging/")
      expect(webpackConfig).toMatchObject({
        devtool: "source-map",
        stats: "normal"
      })
    })
  })
})

Version data entries

2 entries across 2 versions & 1 rubygems

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