Skip to content

Commit

Permalink
Fixes e2e tests (#326)
Browse files Browse the repository at this point in the history
* WIP

* change e2e tests to use promises

* fixing proto
  • Loading branch information
ccpricenytimes authored and delambo committed Nov 18, 2016
1 parent 4e4cc7d commit 12945a9
Showing 1 changed file with 47 additions and 35 deletions.
82 changes: 47 additions & 35 deletions e2e_tests/tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,50 +89,62 @@ describe('KYT CLI', () => {
// eslint-disable-next-line
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000000;

it('starts the app', (done) => {
it('starts the app', () => {
let testPass;
shell.exec('npm run build');
const child = shell.exec('npm run start', () => {
done();
});
child.stdout.on('data', (data) => {
if (data.includes('Server running')) {
shell.exec('sleep 3');
const output = shell.exec('curl -I localhost:3100');
expect(output.includes('200'));
kill(child.pid);
}
const exec = new Promise((resolve) => {
const child = shell.exec('npm run start', () => {
resolve(testPass);
});
child.stdout.on('data', (data) => {
if (data.includes('Server running')) {
shell.exec('sleep 3');
const output = shell.exec('curl -I localhost:3100');
testPass = output.stdout.includes('200');
kill(child.pid);
}
});
});
return exec.then(test => expect(test).toBe(true));
});


it('dev', (done) => {
const child = shell.exec('npm run dev', () => {
done();
});
child.stdout.on('data', (data) => {
if (data.includes('✅ Development started')) {
shell.exec('sleep 2');
const output = shell.exec('curl -I localhost:3100');
expect(output.includes('200'));
kill(child.pid);
}
it('dev', () => {
let testPass;
const exec = new Promise((resolve) => {
const child = shell.exec('npm run dev', () => {
resolve(testPass);
});
child.stdout.on('data', (data) => {
if (data.includes('✅ Development started')) {
shell.exec('sleep 2');
const output = shell.exec('curl -I localhost:3100');
testPass = output.stdout.includes('200');
kill(child.pid);
}
});
});
return exec.then(test => expect(test).toBe(true));
});

it('proto', (done) => {
const child = shell.exec('npm run proto', () => {
done();
});
let stillAlive = true;
child.stdout.on('data', (data) => {
if (data.includes('webpack: bundle is now VALID.') && stillAlive) {
stillAlive = false;
shell.exec('sleep 2');
const output = shell.exec('curl -I localhost:3102/prototype');
expect(output.includes('200'));
kill(child.pid);
}
it('proto', () => {
const exec = new Promise((resolve) => {
let testPass;
const child = shell.exec('npm run proto', () => {
resolve(testPass);
});
let stillAlive = true;
child.stdout.on('data', (data) => {
if (data.includes('webpack: bundle is now VALID.') && stillAlive) {
stillAlive = false;
shell.exec('sleep 5');
const output = shell.exec('curl -I localhost:3102/prototype/');
testPass = output.stdout.includes('404');
kill(child.pid);
}
});
});
return exec.then(test => expect(test).toBe(true));
});

afterAll(() => {
Expand Down

0 comments on commit 12945a9

Please sign in to comment.