@@ -25,6 +25,18 @@ function createWebpackConfig(outputDirName = '', command, argv = {}) {
25
25
) ;
26
26
}
27
27
28
+ function convertToManifestPath ( assetSrc , webpackConfig ) {
29
+ const manifestData = JSON . parse (
30
+ fs . readFileSync ( path . join ( webpackConfig . outputPath , 'manifest.json' ) , 'utf8' )
31
+ ) ;
32
+
33
+ if ( typeof manifestData [ assetSrc ] === 'undefined' ) {
34
+ throw new Error ( `Path ${ assetSrc } not found in manifest!` ) ;
35
+ }
36
+
37
+ return manifestData [ assetSrc ] ;
38
+ }
39
+
28
40
describe ( 'Functional tests using webpack' , function ( ) {
29
41
// being functional tests, these can take quite long
30
42
this . timeout ( 5000 ) ;
@@ -101,7 +113,10 @@ describe('Functional tests using webpack', function() {
101
113
102
114
testSetup . requestTestPage (
103
115
path . join ( config . getContext ( ) , 'public' ) ,
104
- [ '/assets/main.js' ] ,
116
+ [
117
+ // purposely load this NOT from the CDN
118
+ 'assets/main.js'
119
+ ] ,
105
120
( browser ) => {
106
121
webpackAssert . assertResourcesLoadedCorrectly ( browser , [
107
122
'0.js' ,
@@ -147,15 +162,13 @@ describe('Functional tests using webpack', function() {
147
162
148
163
testSetup . requestTestPage (
149
164
path . join ( config . getContext ( ) , 'public' ) ,
150
- [ '/assets/main.js' ] ,
165
+ [
166
+ convertToManifestPath ( 'assets/main.js' , config )
167
+ ] ,
151
168
( browser ) => {
152
169
webpackAssert . assertResourcesLoadedCorrectly ( browser , [
153
170
'0.js' ,
154
- // guarantee that we assert that main.js is loaded from the
155
- // main server, as it's simply a script tag to main.js on the page
156
- // we did this to check that the internally-loaded assets
157
- // use the CDN, even if the entry point does not
158
- 'http://127.0.0.1:8080/assets/main.js'
171
+ 'main.js'
159
172
] ) ;
160
173
161
174
done ( ) ;
@@ -179,7 +192,9 @@ describe('Functional tests using webpack', function() {
179
192
testSetup . requestTestPage (
180
193
// the webroot will not include the /subdirectory/build part
181
194
path . join ( config . getContext ( ) , '' ) ,
182
- [ '/subdirectory/build/main.js' ] ,
195
+ [
196
+ convertToManifestPath ( 'build/main.js' , config )
197
+ ] ,
183
198
( browser ) => {
184
199
webpackAssert . assertResourcesLoadedCorrectly ( browser , [
185
200
'http://127.0.0.1:8080/subdirectory/build/0.js' ,
0 commit comments