Files
cypress/npm/webpack-dev-server/test/unit/makeWebpackConfig.spec.ts
Lachlan Miller 8e894a0fdb fix(webpack-dev-server): remove output.publicPath from webpack-dev-server (#15839)
* fix: remove publicPath in react-scripts if it is present

* fix: remove publicPath in react-scripts if it is present

* fix: remove publicPath in webpack-dev-server regardless

* fix: add root path

* chore: revert

* fix: remove user base path

* remove unused function

* test: add unit test for make webpack config

* chore: make purpose for fake url more clear

* do not include local filesystem path in snapshot
2021-04-09 08:23:01 -04:00

32 lines
1013 B
TypeScript

import { expect } from 'chai'
import snapshot from 'snap-shot-it'
import { makeWebpackConfig } from '../../src/makeWebpackConfig'
describe('makeWebpackConfig', () => {
it('ignores userland webpack `output.publicPath`', async () => {
const actual = await makeWebpackConfig({
output: {
publicPath: '/this-will-be-ignored',
},
}, {
devServerPublicPathRoute: '/test-public-path',
isOpenMode: true,
supportFile: '/support.js',
projectRoot: '.',
files: [],
})
// plugins contain circular deps which cannot be serialized in a snapshot.
// instead just compare the name and order of the plugins.
// @ts-expect-error
actual.plugins = actual.plugins.map((p) => p.constructor.name)
// these will include paths from the user's local file system, so we should not include them the snapshot
delete actual.output.path
delete actual.entry
expect(actual.output.publicPath).to.eq('/test-public-path/')
snapshot(actual)
})
})