This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mocha.prototype.run = function (fn) { | |
var suite = this.suite; | |
var options = this.options; | |
options.files = this.files; | |
var runner = new Runner(suite, options.delay); | |
createStatsCollector(runner); | |
var reporter = new this._reporter(runner, options); | |
const noop = () => ""; | |
function done(failures) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mocha.prototype.loadFilesAsync = async function () { | |
var self = this; | |
var suite = this.suite; | |
for (let file of this.files) { | |
// preload | |
suite.emit(Suite.constants.EVENT_FILE_PRE_REQUIRE, global, file, self); | |
// load | |
file = path.resolve(file); | |
const result = await require(file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function runMocha(mocha, options) { | |
const { spec = [] } = options; | |
// if options.watch watchRun() | |
// singleRun | |
// collectFiles and lookupFiles here | |
mocha.files = spec; | |
await mocha.loadFilesAsync(); | |
return mocha.run(exitMochaLater); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Mocha(options) { | |
this.files = []; | |
this.options = options; | |
// lib/context.js. empty context | |
function Context() {} | |
// root suite | |
this.suite = new Suite("", new Context(), true); | |
this.ui(options.ui).reporter(options.reporter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bdd: function bddInterface(suite) { | |
var suites = [suite]; | |
suite.on(Suite.constants.EVENT_FILE_PRE_REQUIRE, function ( | |
context, | |
file, | |
mocha | |
) { | |
var common = Mocha.interfaces.common(suites, context, mocha); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib cli/cli.js main() | |
const argv = process.argv.slice(2); | |
// lib/cli/options loadOptions() | |
var args = yargsParser.detailed(argv).argv; | |
args._ = Array.from(new Set(args._)); | |
yargs() | |
.scriptName("our_mocha") | |
.command(commands.run) | |
.fail((msg, err, yargs) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const builder = (yargs) => { | |
// cli/run.js builder() | |
return yargs | |
.options({ | |
config: { | |
config: true, | |
description: "Path to config file", | |
}, | |
reporter: { | |
default: defaults.reporter, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. User requests (dns lookup etc) | |
2. Server receives request | |
- Express | |
- Returns below in 0.25ms. | |
<html> | |
<script google-analytics> | |
<body> | |
<div>hey there</div> | |
<script app.js> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Process program | |
ast.program.body.map(stnmt => { | |
switch (stnmt.type) { | |
case "FunctionDeclaration": | |
stnmt.params.map(arg => { | |
// Does arg has a type annotation? | |
if (arg.typeAnnotation) { | |
const argType = arg.typeAnnotation.typeAnnotation.type; | |
// Is type annotation valid | |
const isValid = typeChecks.annotationCheck(argType); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const errors = []; | |
const ANNOTATED_TYPES = { | |
NumberTypeAnnotation: "number", | |
GenericTypeAnnotation: true | |
}; | |
// Logic for type checks | |
const typeChecks = { | |
expression: (declarationFullType, callerFullArg) => { |