Skip to content

chore(tests): add prod env e2e test #1394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions tests/e2e/e2e_workflow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,47 +177,6 @@ describe('Basic end-to-end Workflow', function () {
});
});

it('Serve and run e2e tests after initial build', function () {
this.timeout(240000);

var ngServePid;

function executor(resolve, reject) {
var serveProcess = child_process.exec(`${ngBin} serve`, { maxBuffer: 500*1024 });
var startedProtractor = false;
ngServePid = serveProcess.pid;

serveProcess.stdout.on('data', (data) => {
if (/webpack: bundle is now VALID/.test(data.toString('utf-8')) && !startedProtractor) {
startedProtractor = true;
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
if (error !== null) {
reject(stderr)
} else {
resolve();
}
});
}
});

serveProcess.stderr.on('data', (data) => {
reject(data);
});
serveProcess.on('close', (code) => {
code === 0 ? resolve() : reject('ng serve command closed with error')
});
}

return new Promise(executor)
.then(() => {
if (ngServePid) treeKill(ngServePid);
})
.catch((msg) => {
if (ngServePid) treeKill(ngServePid);
throw new Error(msg);
});
});

it('Can create a test component using `ng generate component test-component`', function () {
this.timeout(10000);
return ng(['generate', 'component', 'test-component']).then(function () {
Expand Down Expand Up @@ -453,7 +412,7 @@ describe('Basic end-to-end Workflow', function () {
expect(indexHtml).to.include('main.bundle.js');
});

it('Serve and run e2e tests after all other commands', function () {
it('Serve and run e2e tests on dev environment', function () {
this.timeout(240000);

var ngServePid;
Expand Down Expand Up @@ -493,6 +452,47 @@ describe('Basic end-to-end Workflow', function () {
throw new Error(msg);
});
});

it('Serve and run e2e tests on prod environment', function () {
this.timeout(240000);

var ngServePid;

function executor(resolve, reject) {
var serveProcess = child_process.exec(`${ngBin} serve -e=prod`, { maxBuffer: 500*1024 });
var startedProtractor = false;
ngServePid = serveProcess.pid;

serveProcess.stdout.on('data', (data) => {
if (/webpack: bundle is now VALID/.test(data.toString('utf-8')) && !startedProtractor) {
startedProtractor = true;
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
if (error !== null) {
reject(stderr)
} else {
resolve();
}
});
}
});

serveProcess.stderr.on('data', (data) => {
reject(data);
});
serveProcess.on('close', (code) => {
code === 0 ? resolve() : reject('ng serve command closed with error')
});
}

return new Promise(executor)
.then(() => {
if (ngServePid) treeKill(ngServePid);
})
.catch((msg) => {
if (ngServePid) treeKill(ngServePid);
throw new Error(msg);
});
});
});

function isMobileTest() {
Expand Down