<commit_before>var assert = require('assert');
var path = require('path');
var del = require('del');
var fs = require('fs');
var async = require('async');
var testee = require('../lib/testee');

describe('Coverage', function() {
  var config = {
    root: path.join(__dirname, '..'),
    reporter: 'Dot',
    coverage: {
      dir: 'test/coverage/',
      reporters: [ 'html' ],
      ignore: [ 'node_modules' ]
    }
  };
  
  describe('QUnit example', function() {
    it('socketio', function(done) {
      del([ 'test/coverage' ]).then(function () {
        testee.test([ 'examples/qunit/index.html' ], [ 'firefox' ], config).fail(function(error) {
          assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');

          async.map([ 'test/coverage/__root__', 'test/coverage/qunit' ], fs.readdir, function (err, files) {
              assert.ok(files[0].indexOf('blogpost.js.html') >= 0, 'reports coverage of blogpost.js');
              assert.ok(files[1].indexOf('test.js.html') >= 0, 'reports coverage of qunit/test.js');
              done();
          });
        });
      });
    });
    it('rest', function(done) {
      del([ 'test/coverage' ]).then(function () {
        testee.test([ 'examples/qunit/rest.html' ], [ 'firefox' ], config).fail(function(error) {
          assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');

          async.map([ 'test/coverage/__root__', 'test/coverage/qunit' ], fs.readdir, function (err, files) {
              assert.ok(files[0].indexOf('blogpost.js.html') >= 0, 'reports coverage of blogpost.js');
              assert.ok(files[1].indexOf('test.js.html') >= 0, 'reports coverage of qunit/test.js');
              done();
          });
        });
      });
    });
  });

  describe('Jasmine example', function() {
    it('socketio', function(done) {
      del([ 'test/coverage' ]).then(function () {
        testee.test([ 'examples/jasmine/index.html' ], [ 'firefox' ], config).fail(function(error) {
          assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');

          async.map([ 'test/coverage/__root__', 'test/coverage/jasmine' ], fs.readdir, function (err, files) {
            assert.ok(files[0].indexOf('blogpost.js.html') >= 0, 'reports coverage of blogpost.js');
            assert.ok(files[1].indexOf('test.js.html') >= 0, 'reports coverage of jasmine/test.js');
            done();
          });
        });
      });
    });
    it('rest', function(done) {
      del([ 'test/coverage' ]).then(function () {
        testee.test([ 'examples/jasmine/rest.html' ], [ 'firefox' ], config).fail(function(error) {
          assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');

          async.map([ 'test/coverage/__root__', 'test/coverage/jasmine' ], fs.readdir, function (err, files) {
            assert.ok(files[0].indexOf('blogpost.js.html') >= 0, 'reports coverage of blogpost.js');
            assert.ok(files[1].indexOf('test.js.html') >= 0, 'reports coverage of jasmine/test.js');
            done();
          });
        });
      });
    });
  });

  describe('Mocha example', function() {
    it('socketio', function(done) {
      del([ 'test/coverage' ]).then(function () {
        testee.test([ 'examples/mocha/index.html' ], [ 'firefox' ], config).fail(function() {
          async.map([ 'test/coverage/__root__', 'test/coverage/mocha' ], fs.readdir, function (err, files) {
            assert.ok(files[0].indexOf('blogpost.js.html') >= 0, 'reports coverage of blogpost.js');
            assert.ok(files[1].indexOf('test.js.html') >= 0, 'reports coverage of mocha/test.js');
            done();
          });
        });
      });
    });
    it('rest', function(done) {
      del([ 'test/coverage' ]).then(function () {
        testee.test([ 'examples/mocha/rest.html' ], [ 'firefox' ], config).fail(function() {
          async.map([ 'test/coverage/__root__', 'test/coverage/mocha' ], fs.readdir, function (err, files) {
            assert.ok(files[0].indexOf('blogpost.js.html') >= 0, 'reports coverage of blogpost.js');
            assert.ok(files[1].indexOf('test.js.html') >= 0, 'reports coverage of mocha/test.js');
            done();
          });
        });
      });
    });
  });
});<commit_msg>refactoring coverage tests<commit_after>var assert = require('assert');
var path = require('path');
var del = require('del');
var fs = require('fs');
var testee = require('../lib/testee');

describe('Coverage', function() {
  var config = {
    root: path.join(__dirname, '..'),
    reporter: 'Dot',
    coverage: {
      dir: 'test/coverage/',
      reporters: [ 'html' ],
      ignore: [ 'node_modules' ]
    }
  };

  beforeEach(function() {
    return del([ 'test/coverage' ]);
  });
  
  describe('QUnit example', function() {
    it('socketio', function() {
      return testee.test([ 'examples/qunit/index.html' ], [ 'firefox' ], config).fail(function(error) {
        assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');
        assert.ok(fs.existsSync('test/coverage/examples/blogpost.js.html'), 'reports coverage of blogpost.js');
        assert.ok(fs.existsSync('test/coverage/examples/qunit/test.js.html'), 'reports coverage of qunit/test.js');
      });
    });

    it('rest', function() {
      return testee.test([ 'examples/qunit/rest.html' ], [ 'firefox' ], config).fail(function(error) {
        assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');
        assert.ok(fs.existsSync('test/coverage/examples/blogpost.js.html'), 'reports coverage of blogpost.js');
        assert.ok(fs.existsSync('test/coverage/examples/qunit/test.js.html'), 'reports coverage of qunit/test.js');
      });
    });
  });

  describe('Jasmine example', function() {
    it('socketio', function() {
      return testee.test([ 'examples/jasmine/index.html' ], [ 'firefox' ], config).fail(function(error) {
        assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');
        assert.ok(fs.existsSync('test/coverage/examples/blogpost.js.html'), 'reports coverage of blogpost.js');
        assert.ok(fs.existsSync('test/coverage/examples/jasmine/test.js.html'), 'reports coverage of jasmine/test.js');
      });
    });

    it('rest', function() {
      return testee.test([ 'examples/jasmine/rest.html' ], [ 'firefox' ], config).fail(function(error) {
        assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');
        assert.ok(fs.existsSync('test/coverage/examples/blogpost.js.html'), 'reports coverage of blogpost.js');
        assert.ok(fs.existsSync('test/coverage/examples/jasmine/test.js.html'), 'reports coverage of jasmine/test.js');
      });
    });
  });

  describe('Mocha example', function() {
    it('socketio', function() {
      return testee.test([ 'examples/mocha/index.html' ], [ 'firefox' ], config).fail(function(error) {
        assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');
        assert.ok(fs.existsSync('test/coverage/examples/blogpost.js.html'), 'reports coverage of blogpost.js');
        assert.ok(fs.existsSync('test/coverage/examples/mocha/test.js.html'), 'reports coverage of mocha/test.js');
      });
    });

    it('rest', function() {
      return testee.test([ 'examples/mocha/rest.html' ], [ 'firefox' ], config).fail(function(error) {
        assert.equal(error.message, 'There were 0 general errors and 1 total test failures.');
        assert.ok(fs.existsSync('test/coverage/examples/blogpost.js.html'), 'reports coverage of blogpost.js');
        assert.ok(fs.existsSync('test/coverage/examples/mocha/test.js.html'), 'reports coverage of mocha/test.js');
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.18617429082545361, 'fraction_numerical': 0.005622284692052134, 'mean_word_length': 2.951034830893488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2187439', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2420, 'n_words': 473}