<commit_before>import HtmlReporter from '../../src/HtmlReporter';
import * as fs from 'fs';
import * as path from 'path';
import {expect} from 'chai';

const exampleMutations = require('./exampleMutations.json');
const exampleSourceFiles = require('./exampleSourceFiles.json');

function expectFileExists(file: string, expected: boolean){
  try{
    fs.readFileSync(file);
    expect(expected, `file ${file} does not exist`).to.be.true;
  }catch(err){
    expect(expected, `file ${file} exists`).to.be.false;
  }
}

describe.only('HtmlReporter with example project', () => {
  let sut: HtmlReporter, baseDir = 'reports/mutation/integrationTest/' + Math.random();

  describe(`with baseDir ${baseDir}`, () => {
    beforeEach(() => {
      sut = new HtmlReporter({ htmlReporter: { baseDir } });
      sut.onAllSourceFilesRead(exampleSourceFiles);
    });

    describe('onAllMutantsTested()', () => {

      beforeEach(() => {
        sut.onAllMutantsTested(exampleMutations);
        return sut.wrapUp();
      });

      it('should have created index.html, Circle.js.html and Add.js.html file in the configured directory', () => {
        expectFileExists(`${baseDir}/index.html`, true);
        expectFileExists(`${baseDir}/Circle.js.html`, true);
        expectFileExists(`${baseDir}/Add.js.html`, true);
      });
    });

    describe('when initiated a second time with empty events', () => {

      beforeEach( () => {
        sut = new HtmlReporter({ htmlReporter: { baseDir } });
        sut.onAllSourceFilesRead([]);
        sut.onAllMutantsTested([]);
        return sut.wrapUp();
      });

      it(`should clean the folder ${baseDir}`, () => { 
        expectFileExists(`${baseDir}/index.html`, false);
        expectFileExists(`${baseDir}/Circle.js.html`, false);
        expectFileExists(`${baseDir}/Add.js.html`, false);
      });
    });

  });


});
<commit_msg>refactor(HtmlReporterSpec) Add logging to debug travis-ci<commit_after>import HtmlReporter from '../../src/HtmlReporter';
import * as fs from 'fs';
import * as path from 'path';
import {expect} from 'chai';

const exampleMutations = require('./exampleMutations.json');
const exampleSourceFiles = require('./exampleSourceFiles.json');

function expectFileExists(file: string, expected: boolean) {
  try {
    fs.readFileSync(file);
    expect(expected, `file ${file} does not exist`).to.be.true;
  } catch (err) {
    expect(expected, `file ${file} exists`).to.be.false;
  }
}

describe.only('HtmlReporter with example project', () => {
  let sut: HtmlReporter, baseDir = 'reports/mutation/integrationTest/' + Math.random();

  describe(`with baseDir ${baseDir}`, () => {
    beforeEach(() => {
      sut = new HtmlReporter({ htmlReporter: { baseDir } });
      sut.onAllSourceFilesRead(exampleSourceFiles);
    });

    describe('onAllMutantsTested()', () => {

      beforeEach(() => {
        sut.onAllMutantsTested(exampleMutations);
        return sut.wrapUp();
      });

      it('should have created index.html, Circle.js.html and Add.js.html file in the configured directory', () => {
        expectFileExists(`${baseDir}/index.html`, true);
        expectFileExists(`${baseDir}/Circle.js.html`, true);
        expectFileExists(`${baseDir}/Add.js.html`, true);
      });

      afterEach(() => {
        console.log(fs.readdirSync(baseDir));
        console.log(path.resolve(baseDir));
      });
    });

    describe('when initiated a second time with empty events', () => {

      beforeEach(() => {
        sut = new HtmlReporter({ htmlReporter: { baseDir } });
        sut.onAllSourceFilesRead([]);
        sut.onAllMutantsTested([]);
        return sut.wrapUp();
      });

      it(`should clean the folder ${baseDir}`, () => {
        expectFileExists(`${baseDir}/index.html`, false);
        expectFileExists(`${baseDir}/Circle.js.html`, false);
        expectFileExists(`${baseDir}/Add.js.html`, false);
      });
    });

  });


});

{'fraction_non_alphanumeric': 0.17344862665310273, 'fraction_numerical': 0.0, 'mean_word_length': 3.288985823336968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '4362828', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1186, 'n_words': 237}