const shell = require('shelljs');
const util = require('../fixtures/util');
const kill = require('../utils/psKill');
const path = require('path');
const fs = require('fs');

// shell.config.silent = true;

describe('razzle start', () => {
  describe('razzle basic example', () => {
    beforeAll(() => {
      shell.cd(path.join(util.rootDir, 'examples/basic'));
    });

    jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000; // eslint-disable-line no-undef

    it('should start a dev server on :3000', () => {
      let outputTest;
      const run = new Promise(resolve => {
        const child = shell.exec('node_modules/.bin/razzle start', () => {
          resolve(outputTest);
        });
        child.stdout.on('data', data => {
          if (data.includes('> Started on port 3000')) {
            shell.exec('sleep 5');
            const output = shell.exec('curl -I localhost:3000');
            outputTest = output.stdout.includes('200');
            kill(child.pid);
          }
        });
      });
      return run.then(test => expect(test).toBe(true));
    });

    jasmine.DEFAULT_TIMEOUT_INTERVAL = 400000; // eslint-disable-line no-undef

    it('should build and run', () => {
      let outputTest;
      shell.exec('node_modules/.bin/razzle build');
      const run = new Promise(resolve => {
        const child = shell.exec('node build/server.js', () => {
          resolve(outputTest);
        });
        child.stdout.on('data', data => {
          if (data.includes('> Started on port 3000')) {
            shell.exec('sleep 5');
            const output = shell.exec('curl -I localhost:3000');
            outputTest = output.stdout.includes('200');
            kill(child.pid);
          }
        });
      });
      return run.then(test => expect(test).toBe(true));
    });

    afterAll(() => {
      shell.rm('-rf', 'build');
      shell.cd(util.rootDir);
    });
  });
});

@@ -589,33 +589,57 @@
 ld = shell.exec(
-'
+%0A          'VERBOSE=true 
 node_modules/.bi
@@ -646,32 +646,42 @@
 n/razzle start',
+%0A         
  () =%3E %7B%0A       
@@ -665,32 +665,34 @@
         () =%3E %7B%0A
+  
           resolv
@@ -706,33 +706,44 @@
 tTest);%0A        
-%7D
+  %7D%0A        
 );%0A        child
@@ -1107,32 +1107,35 @@
 ));%0A    %7D);%0A%0A   
+ //
  jasmine.DEFAULT

Set VERBOSE=true, comment out jasmine timeout for CI