2017-02-18 20:14:10 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* DO NOT EDIT THIS FILE
|
|
|
|
* For FCC testing purposes!
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
const analyser = require('./assertion-analyser');
|
|
|
|
const EventEmitter = require('events').EventEmitter;
|
2017-02-18 20:14:10 +01:00
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
const Mocha = require('mocha'),
|
2017-02-18 20:14:10 +01:00
|
|
|
fs = require('fs'),
|
|
|
|
path = require('path');
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let mocha = new Mocha();
|
|
|
|
let testDir = './tests'
|
2017-02-18 20:14:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Add each .js file to the mocha instance
|
|
|
|
fs.readdirSync(testDir).filter(function(file){
|
|
|
|
// Only keep the .js files
|
|
|
|
return file.substr(-3) === '.js';
|
|
|
|
|
|
|
|
}).forEach(function(file){
|
|
|
|
mocha.addFile(
|
|
|
|
path.join(testDir, file)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let emitter = new EventEmitter();
|
2017-02-18 20:14:10 +01:00
|
|
|
emitter.run = function() {
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let tests = [];
|
|
|
|
let context = "";
|
|
|
|
let separator = ' -> ';
|
2017-02-18 20:14:10 +01:00
|
|
|
// Run the tests.
|
|
|
|
try {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let runner = mocha.ui('tdd').run()
|
2017-02-18 20:14:10 +01:00
|
|
|
.on('test end', function(test) {
|
|
|
|
// remove comments
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let body = test.body.replace(/\/\/.*\n|\/\*.*\*\//g, '');
|
2017-02-18 20:14:10 +01:00
|
|
|
// collapse spaces
|
|
|
|
body = body.replace(/\s+/g,' ');
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let obj = {
|
2017-02-18 20:14:10 +01:00
|
|
|
title: test.title,
|
|
|
|
context: context.slice(0, -separator.length),
|
|
|
|
state: test.state,
|
|
|
|
// body: body,
|
|
|
|
assertions: analyser(body)
|
|
|
|
};
|
|
|
|
tests.push(obj);
|
|
|
|
})
|
|
|
|
.on('end', function() {
|
|
|
|
emitter.report = tests;
|
|
|
|
emitter.emit('done', tests)
|
|
|
|
})
|
|
|
|
.on('suite', function(s) {
|
|
|
|
context += (s.title + separator);
|
|
|
|
|
|
|
|
})
|
|
|
|
.on('suite end', function(s) {
|
|
|
|
context = context.slice(0, -(s.title.length + separator.length))
|
|
|
|
})
|
|
|
|
} catch(e) {
|
|
|
|
throw(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = emitter;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mocha.runner Events:
|
|
|
|
* can be used to build a better custom report
|
|
|
|
*
|
|
|
|
* - `start` execution started
|
|
|
|
* - `end` execution complete
|
|
|
|
* - `suite` (suite) test suite execution started
|
|
|
|
* - `suite end` (suite) all tests (and sub-suites) have finished
|
|
|
|
* - `test` (test) test execution started
|
|
|
|
* - `test end` (test) test completed
|
|
|
|
* - `hook` (hook) hook execution started
|
|
|
|
* - `hook end` (hook) hook complete
|
|
|
|
* - `pass` (test) test passed
|
|
|
|
* - `fail` (test, err) test failed
|
|
|
|
* - `pending` (test) test pending
|
|
|
|
*/
|