Skip to content

Commit b4c5a81

Browse files
committed
enhancing createSharedEntry test
1 parent 4449182 commit b4c5a81

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

fixtures/js/print_to_app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
document.getElementById('app').innerHTML = 'Welcome to Encore!';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./arrow_function');

test/functional.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,23 +561,50 @@ describe('Functional tests using webpack', function() {
561561
it('createdSharedEntry() creates commons files', (done) => {
562562
const config = createWebpackConfig('www/build', 'dev');
563563
config.setPublicPath('/build');
564-
config.addEntry('main', ['./js/no_require', './js/code_splitting']);
564+
config.addEntry('main', ['./js/no_require', './js/code_splitting', './js/arrow_function', './js/print_to_app']);
565565
config.addEntry('other', ['./js/no_require']);
566-
config.createSharedEntry('vendor', './js/no_require');
566+
config.createSharedEntry('vendor', ['./js/no_require', './js/requires_arrow_function']);
567567

568568
testSetup.runWebpack(config, (webpackAssert) => {
569569
// check the file is extracted correctly
570570
webpackAssert.assertOutputFileContains(
571571
'vendor.js',
572572
'i am the no_require.js file'
573573
);
574-
// we should also have a manifest file with the webpack bootstrap code
575574
webpackAssert.assertOutputFileContains(
576-
'manifest.js',
575+
'vendor.js',
576+
'arrow_function.js is ready for action'
577+
);
578+
579+
// check that there is NOT duplication
580+
webpackAssert.assertOutputFileDoesNotContain(
581+
'main.js',
582+
'i am the no_require.js file'
583+
);
584+
webpackAssert.assertOutputFileDoesNotContain(
585+
'main.js',
586+
'arrow_function.js is ready for action'
587+
);
588+
589+
// we should also have a runtime file with the webpack bootstrap code
590+
webpackAssert.assertOutputFileContains(
591+
'runtime.js',
577592
'function __webpack_require__'
578593
);
579594

580-
done();
595+
testSetup.requestTestPage(
596+
path.join(config.getContext(), 'www'),
597+
[
598+
'build/runtime.js',
599+
'build/vendor.js',
600+
'build/main.js'
601+
],
602+
(browser) => {
603+
// assert that the javascript executed
604+
browser.assert.text('#app', 'Welcome to Encore!');
605+
done();
606+
}
607+
);
581608
});
582609
});
583610

0 commit comments

Comments
 (0)