forked from rails/webpacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
development.js
42 lines (34 loc) · 1.38 KB
/
development.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* test expect, describe, afterAll, beforeEach */
const { resolve } = require('path')
const { chdirTestApp, chdirCwd } = require('../utils/helpers')
chdirTestApp()
describe('Development environment', () => {
afterAll(chdirCwd)
describe('webpackConfig', () => {
beforeEach(() => jest.resetModules())
test('should use development config and environment including devServer if WEBPACK_DEV_SERVER', () => {
process.env.RAILS_ENV = 'development'
process.env.NODE_ENV = 'development'
process.env.WEBPACK_DEV_SERVER = 'YES'
const { webpackConfig } = require('../index')
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
expect(webpackConfig.output.publicPath).toEqual('/packs/')
expect(webpackConfig).toMatchObject({
devServer: {
host: 'localhost',
port: 3035,
injectClient: true
}
})
})
test('should use development config and environment if WEBPACK_DEV_SERVER', () => {
process.env.RAILS_ENV = 'development'
process.env.NODE_ENV = 'development'
process.env.WEBPACK_DEV_SERVER = undefined
const { webpackConfig } = require('../index')
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
expect(webpackConfig.output.publicPath).toEqual('/packs/')
expect(webpackConfig.devServer).toEqual(undefined)
})
})
})