<commit_before>// import { expect } from 'chai';
// import request from 'supertest';
var expect = require('chai').expect;
var request = require('supertest');

// ----------------------------------------------------------------------
// 'really-need' replaces Node's require with a more powerful version. In 
// addition to a path, it accepts an options object; one of the available
// options is to bust the cache before loading a module.
// ----------------------------------------------------------------------
// require = require('really-need');
// 
// UPDATE 01/30/17:
// ----------------
// 'really-need' does not work for node versions above v4.0.0.  We're
// using v6.1.0.  I'll keep the 'really-need' solution in the code
// (but commented out) as an educational resource, but it will not be
// utilized moving forward.

describe('Loading express', function () {
  
  var server;
  
  beforeEach(function () {
    // Line below utilizes 'really-need':
    // server = require('../../server/server.js', { bustCache: true });
    delete require.cache[require.resolve('../../server/server.js')];
    server = require('../../server/server.js');
  });

  afterEach(function () {
    server.close();
    console.log('Server now closed.');
  });

  it('Responds to /', function testSlash(done) {
    request(server)
      .get('/')
      .expect(200, done);
  });

  it('404 errors everything else', function testPath(done) {
    console.log('Test 404');
    request(server)
      .get('/foo/bar')
      .expect(404, done);
  });

});<commit_msg>(test) Refactored to ES6 syntax.  (Still need to refactor 'require's to 'import's later)<commit_after>// import { expect } from 'chai';
// import request from 'supertest';
const expect = require('chai').expect;
const request = require('supertest');

// ----------------------------------------------------------------------
// 'really-need' replaces Node's require with a more powerful version. In 
// addition to a path, it accepts an options object; one of the available
// options is to bust the cache before loading a module.
// ----------------------------------------------------------------------
// require = require('really-need');
// 
// UPDATE 01/30/17:
// ----------------
// 'really-need' does not work for node versions above v4.0.0.  We're
// using v6.1.0.  I'll keep the 'really-need' solution in the code
// (but commented out) as an educational resource, but it will not be
// utilized moving forward.

describe('Loading express', () => {
  
  let server;
  
  beforeEach( () => {
    // Line below utilizes 'really-need':
    // server = require('../../server/server.js', { bustCache: true });
    delete require.cache[require.resolve('../../server/server.js')];
    server = require('../../server/server.js');
  });

  afterEach( () => {
    server.close();
    console.log('Server now closed.');
  });

  it('Responds to /', (done) => {
    request(server)
      .get('/')
      .expect(200, done);
  });

  it('404 errors everything else', (done) => {
    console.log('Test 404');
    request(server)
      .get('/foo/bar')
      .expect(404, done);
  });

});
{'fraction_non_alphanumeric': 0.2571884984025559, 'fraction_numerical': 0.015654952076677317, 'mean_word_length': 2.0192864030858244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '7117880', 'n_tokens_mistral': 914, 'n_tokens_neox': 851, 'n_words': 269}