Skip to content

Commit a59eed3

Browse files
committed
fix some e2e tests, simplify mobile prod build
1 parent 9a7a4d5 commit a59eed3

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

addon/ng2/models/webpack-build-mobile.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as webpack from 'webpack';
22
import * as path from 'path';
3-
import * as SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';
43
import * as OfflinePlugin from 'offline-plugin';
54
import { PrerenderWebpackPlugin } from '../utilities/prerender-webpack-plugin.ts'
65

@@ -18,9 +17,11 @@ export const getWebpackMobileConfigPartial = function (projectRoot: string) {
1817

1918
export const getWebpackMobileProdConfigPartial = function (projectRoot: string) {
2019
return {
20+
entry: {
21+
'sw-install': path.resolve(__dirname, '../utilities/sw-install.js')
22+
},
2123
plugins: [
22-
new OfflinePlugin(),
23-
new SingleEntryPlugin(__dirname, path.join(__dirname, '../utilities/sw-install.js'), 'sw-install'),
24+
new OfflinePlugin()
2425
]
2526
}
2627
};

tests/e2e/e2e_workflow.spec.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ describe('Basic end-to-end Workflow', function () {
6666
// stuck to the first build done
6767
sh.exec(`${ngBin} build -prod`);
6868
expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
69+
const indexHtml = fs.readFileSync(path.join(process.cwd(), 'dist/index.html'), 'utf-8');
70+
// Check for cache busting hash script src
71+
expect(indexHtml).to.match(/main\.[0-9a-f]{20}\.bundle\.js/);
72+
// Also does not create new things in GIT.
73+
expect(sh.exec('git status --porcelain').output).to.be.equal(undefined);
74+
});
75+
76+
it('Supports production builds config file replacement', function() {
6977
var mainBundlePath = path.join(process.cwd(), 'dist', 'main.js');
7078
var mainBundleContent = fs.readFileSync(mainBundlePath, { encoding: 'utf8' });
7179
// production: true minimized turns into production:!0
7280
expect(mainBundleContent).to.include('production:!0');
73-
// Also does not create new things in GIT.
74-
expect(sh.exec('git status --porcelain').output).to.be.equal(undefined);
7581
});
7682

7783
it('Can run `ng build` in created project', function () {
@@ -83,11 +89,9 @@ describe('Basic end-to-end Workflow', function () {
8389
})
8490
.then(function () {
8591
expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
86-
8792
// Check the index.html to have no handlebar tokens in it.
8893
const indexHtml = fs.readFileSync(path.join(process.cwd(), 'dist/index.html'), 'utf-8');
89-
expect(indexHtml).to.not.include('{{');
90-
expect(indexHtml).to.include('vendor/es6-shim/es6-shim.js');
94+
expect(indexHtml).to.include('main.bundle.js');
9195
})
9296
.then(function () {
9397
// Also does not create new things in GIT.
@@ -139,12 +143,12 @@ describe('Basic end-to-end Workflow', function () {
139143
var ngServePid;
140144

141145
function executor(resolve, reject) {
142-
var serveProcess = child_process.exec(`${ngBin} serve`);
146+
var serveProcess = child_process.exec(`${ngBin} serve`, {maxBuffer: 500*1024});
143147
var startedProtractor = false;
144148
ngServePid = serveProcess.pid;
145149

146150
serveProcess.stdout.on('data', (data) => {
147-
if (/Build successful/.test(data) && !startedProtractor) {
151+
if (/webpack: bundle is now VALID/.test(data.toString('utf-8')) && !startedProtractor) {
148152
startedProtractor = true;
149153
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
150154
if (error !== null) {
@@ -153,8 +157,6 @@ describe('Basic end-to-end Workflow', function () {
153157
resolve();
154158
}
155159
});
156-
} else if (/ failed with:/.test(data)) {
157-
reject(data);
158160
}
159161
});
160162

@@ -441,12 +443,12 @@ describe('Basic end-to-end Workflow', function () {
441443
var ngServePid;
442444

443445
function executor(resolve, reject) {
444-
var serveProcess = child_process.exec(`${ngBin} serve`);
446+
var serveProcess = child_process.exec(`${ngBin} serve`, {maxBuffer: 500*1024});
445447
var startedProtractor = false;
446448
ngServePid = serveProcess.pid;
447449

448450
serveProcess.stdout.on('data', (data) => {
449-
if (/Build successful/.test(data) && !startedProtractor) {
451+
if (/webpack: bundle is now VALID/.test(data.toString('utf-8')) && !startedProtractor) {
450452
startedProtractor = true;
451453
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
452454
if (error !== null) {
@@ -455,8 +457,6 @@ describe('Basic end-to-end Workflow', function () {
455457
resolve();
456458
}
457459
});
458-
} else if (/ failed with:/.test(data)) {
459-
reject(data);
460460
}
461461
});
462462

0 commit comments

Comments
 (0)