<commit_before>/**
 * @jest-environment node
 */
'use strict';

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

const silent = true;
shell.config.verbose = !silent;
shell.config.silent = silent;

const spew = false;

const stageName = 'stage-start';

describe('razzle start', () => {
  describe('razzle basic example', () => {
    beforeAll(() => {
      util.teardownStage(stageName);
    });

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

    it('should start a dev server', () => {
      util.setupStageWithExample(stageName, 'basic');
      let outputTest;
      const run = new Promise(resolve => {
        const child = shell.exec(`${path.join('../node_modules/.bin/razzle')} start --verbose`, () => {
          resolve(outputTest);
        });
        child.stdout.on('data', data => {
          if (!silent) console.log(data);
          if (data.includes('Server-side HMR Enabled!')) {
            shell.exec('sleep 5');
            const devServerOutput = shell.exec(
              'curl -sb -o "" localhost:3001/static/js/bundle.js'
            );
            if (spew) console.log('devServerOutput:' + devServerOutput.stdout);
            outputTest = devServerOutput.stdout.includes('React');
            kill(child.pid);
          }
        });
        child.stderr.on('data', data => {
          if (!silent) console.log('stderr:' + data);
        });
      });
      return run.then(test => expect(test).toBeTruthy());
    });

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

    it('should start a dev server on different port', () => {
      util.setupStageWithExample(stageName, 'with-custom-devserver-options');
      let outputTest;
      const run = new Promise(resolve => {
        const child = shell.exec(`${path.join('../node_modules/.bin/razzle')} start --verbose`, () => {
          resolve(outputTest);
        });
        child.stdout.on('data', data => {
          if (!silent) console.log(data);
          if (data.includes('Server-side HMR Enabled!')) {
            shell.exec('sleep 5');
            const devServerOutput = shell.exec(
              'curl -sb -o "" localhost:3002/static/js/bundle.js'
            );
            if (spew) console.log('devServerOutput:' + devServerOutput.stdout);
            outputTest = devServerOutput.stdout.includes(
              'index.js?http://localhost:3002'
            );
            kill(child.pid);
          }
        });
        child.stderr.on('data', data => {
          if (!silent) console.log('stderr:' + data);
        });
      });<commit_msg>fix: try making tests pass<commit_after>/**
 * @jest-environment node
 */
'use strict';

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

const silent = true;
shell.config.verbose = !silent;
shell.config.silent = silent;

const spew = false;

const stageName = 'stage-start';

describe('razzle start', () => {
  describe('razzle basic example', () => {
    beforeAll(() => {
      util.teardownStage(stageName);
    });

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

    it('should start a dev server', () => {
      util.setupStageWithExample(stageName, 'basic');
      let outputTest;
      const run = new Promise(resolve => {
        const child = shell.exec(`${path.join('../node_modules/.bin/razzle')} start --verbose`, () => {
          resolve(outputTest);
        });
        child.stdout.on('data', data => {
          if (!silent) console.log(data);
          if (data.includes('Server-side HMR Enabled!') && !outputTest) {
            shell.exec('sleep 5');
            const devServerOutput = shell.exec(
              'curl -sb -o "" localhost:3001/static/js/bundle.js'
            );
            if (spew) console.log('devServerOutput:' + devServerOutput.stdout);
            outputTest = devServerOutput.stdout.includes('React');
            kill(child.pid);
          }
        });
        child.stderr.on('data', data => {
          if (!silent) console.log('stderr:' + data);
        });
      });
      return run.then(test => expect(test).toBeTruthy());
    });

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

    it('should start a dev server on different port', () => {
      util.setupStageWithExample(stageName, 'with-custom-devserver-options');
      let outputTest;
      const run = new Promise(resolve => {
        const child = shell.exec(`${path.join('../node_modules/.bin/razzle')} start --verbose`, () => {
          resolve(outputTest);
        });
        child.stdout.on('data', data => {
          if (!silent) console.log(data);
          if (data.includes('Server-side HMR Enabled!') && !outputTest) {
            shell.exec('sleep 5');
            const devServerOutput = shell.exec(
              'curl -sb -o "" localhost:3002/static/js/bundle.js'
            );
            if (spew) console.log('devServerOutput:' + devServerOutput.stdout);
            outputTest = devServerOutput.stdout.includes(
              'index.js?http://localhost:3002'
            );
            kill(child.pid);
          }
        });
        child.stderr.on('data', data => {
          if (!silent) console.log('stderr:' + data);
        });
      });
{'fraction_non_alphanumeric': 0.16516626860187397, 'fraction_numerical': 0.01028844387286423, 'mean_word_length': 2.2775436484045755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4205410', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1571, 'n_words': 310}