Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include "test" in environment whitelist #1513

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package/__tests__/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const { chdirTestApp, chdirCwd } = require('../utils/helpers')
chdirTestApp()

describe('Development environment', () => {
beforeEach(() => {
jest.resetModules()
})

afterAll(chdirCwd)

describe('toWebpackConfig', () => {
Expand Down
5 changes: 5 additions & 0 deletions package/__tests__/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ const { chdirTestApp, chdirCwd } = require('../utils/helpers')
chdirTestApp()

describe('Production environment', () => {
beforeEach(() => {
jest.resetModules();
})

afterAll(chdirCwd)

describe('toWebpackConfig', () => {
beforeEach(() => jest.resetModules())

test('should use production config and environment', () => {
process.env.RAILS_ENV = 'production'
process.env.NODE_ENV = 'production'
const { environment } = require('../index')

const config = environment.toWebpackConfig()
Expand Down
5 changes: 5 additions & 0 deletions package/__tests__/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ const { chdirTestApp, chdirCwd } = require('../utils/helpers')
chdirTestApp()

describe('Custom environment', () => {
beforeEach(() => {
jest.resetModules()
})

afterAll(chdirCwd)

describe('toWebpackConfig', () => {
beforeEach(() => jest.resetModules())

test('should use staging config and production environment', () => {
process.env.RAILS_ENV = 'staging'
process.env.NODE_ENV = 'staging'
const { environment } = require('../index')

const config = environment.toWebpackConfig()
Expand Down
5 changes: 5 additions & 0 deletions package/__tests__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ const { chdirTestApp, chdirCwd } = require('../utils/helpers')
chdirTestApp()

describe('Test environment', () => {
beforeEach(() => {
jest.resetModules()
})

afterAll(chdirCwd)

describe('toWebpackConfig', () => {
beforeEach(() => jest.resetModules())

test('should use test config and production environment', () => {
process.env.RAILS_ENV = 'test'
process.env.NODE_ENV = 'test'
const { environment } = require('../index')

const config = environment.toWebpackConfig()
Expand Down
2 changes: 1 addition & 1 deletion package/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { resolve } = require('path')
const { safeLoad } = require('js-yaml')
const { readFileSync } = require('fs')

const NODE_ENVIRONMENTS = ['development', 'production']
const NODE_ENVIRONMENTS = ['development', 'test', 'production']
const DEFAULT = 'production'
const configPath = resolve('config', 'webpacker.yml')

Expand Down