Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): stricter reg exp to redirect sockjs client path (#2069)
* fix(client): stricter reg exp to redirect sockjs client path * fix(client): check resource context for normal module replacement * fix(client): remove dev server string from context path * fix(client): remove console logs * fix(client): fixed resource context match to use cwd
- Loading branch information
1 parent
bdf8444
commit d3da508
Showing
5 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use strict'; | ||
|
||
const testServer = require('../helpers/test-server'); | ||
const config = require('../fixtures/client-config/webpack.config'); | ||
const runBrowser = require('../helpers/run-browser'); | ||
const port = require('../ports-map').Iframe; | ||
|
||
// iframe mode should be tested while still supported, because | ||
// its sources differ from those of inline mode, which can cause unexpected | ||
// breaking changes: https://github.com/webpack/webpack-dev-server/issues/2006 | ||
describe('Client iframe console.log', () => { | ||
const baseOptions = { | ||
port, | ||
host: '0.0.0.0', | ||
}; | ||
const cases = [ | ||
{ | ||
title: 'hot disabled', | ||
options: { | ||
hot: false, | ||
}, | ||
}, | ||
{ | ||
title: 'hot enabled', | ||
options: { | ||
hot: true, | ||
}, | ||
}, | ||
{ | ||
title: 'liveReload disabled', | ||
options: { | ||
liveReload: false, | ||
}, | ||
}, | ||
{ | ||
title: 'liveReload enabled', | ||
options: { | ||
liveReload: true, | ||
}, | ||
}, | ||
{ | ||
title: 'clientLogLevel is silent', | ||
options: { | ||
clientLogLevel: 'silent', | ||
}, | ||
}, | ||
]; | ||
|
||
for (const { title, options } of cases) { | ||
it(title, () => { | ||
const res = []; | ||
const testOptions = Object.assign({}, baseOptions, options); | ||
|
||
// TODO: use async/await when Node.js v6 support is dropped | ||
return Promise.resolve() | ||
.then(() => { | ||
return new Promise((resolve) => { | ||
testServer.startAwaitingCompilation(config, testOptions, resolve); | ||
}); | ||
}) | ||
.then(runBrowser) | ||
.then(({ page, browser }) => { | ||
return new Promise((resolve) => { | ||
page.goto(`http://localhost:${port}/webpack-dev-server/main`); | ||
page.on('console', ({ _text }) => { | ||
res.push(_text); | ||
}); | ||
setTimeout(() => { | ||
browser.close().then(() => { | ||
expect(res).toMatchSnapshot(); | ||
resolve(); | ||
}); | ||
}, 3000); | ||
}); | ||
}) | ||
.then(() => { | ||
return new Promise((resolve) => { | ||
testServer.close(resolve); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Client iframe console.log clientLogLevel is silent 1`] = ` | ||
Array [ | ||
"Hey.", | ||
] | ||
`; | ||
|
||
exports[`Client iframe console.log hot disabled 1`] = ` | ||
Array [ | ||
"Hey.", | ||
"[WDS] Live Reloading enabled.", | ||
] | ||
`; | ||
|
||
exports[`Client iframe console.log hot enabled 1`] = ` | ||
Array [ | ||
"[HMR] Waiting for update signal from WDS...", | ||
"Hey.", | ||
"[WDS] Hot Module Replacement enabled.", | ||
"[WDS] Live Reloading enabled.", | ||
] | ||
`; | ||
|
||
exports[`Client iframe console.log liveReload disabled 1`] = ` | ||
Array [ | ||
"Hey.", | ||
] | ||
`; | ||
|
||
exports[`Client iframe console.log liveReload enabled 1`] = ` | ||
Array [ | ||
"Hey.", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters