diff --git a/e2e_tests/tests/cli.test.js b/e2e_tests/tests/cli.test.js index 6fb042eb1..f6216e941 100644 --- a/e2e_tests/tests/cli.test.js +++ b/e2e_tests/tests/cli.test.js @@ -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(() => {