Skip to content

Instantly share code, notes, and snippets.

View craigtaub's full-sized avatar

Craig Taub craigtaub

View GitHub Profile
@craigtaub
craigtaub / Markdown reporter.md
Last active April 9, 2024 01:37
md-reporter.md

TOC

Add

should add numbers correctly.

equal(add(2, 3), 5);
@craigtaub
craigtaub / React-Hooks.js
Last active April 22, 2023 16:58
Nested React Hooks
// Engine
const React = {
index: 0,
state: [],
useEffect: (callback, dependencies) => {
const cachedIndex = React.index;
const hasChanged = dependencies !== React.state[cachedIndex];
if (dependencies === undefined || hasChanged) {
callback();
=== Machine on wifi , dev on IE8
machine:
wifi to iplayer_mobile
-any turn proxies off
unplug eth
dev:
proxies off and extacess on
#reithproxies off
#extaccess pal-ct
Runner.prototype.runTests = function(callback) {
function next() {
// grab next test
test = tests.shift()
// no tests left, run callback running next suite
if (!test) callback()
// run beforeEach hooks
hooks(HOOK_TYPE_BEFORE_EACH, () => {
runTest(err => {
if (err) {
Runner.prototype.hooks = function(name, callback) {
function next(suite) {
if (!suite) callback()
hook(name, () => {
next(suites.pop()) // run hooks for next suite
})
}
next()
}
Runner.prototype.runTest = function(fn) {
var self = this
var test = this.test
if (!test) return
try {
// 1. run the test
test.run(fn)
} catch (err) {
Runner.prototype.hook = function (name, fn) {
// 1. for current suite, get hooks with name x
var hooks = this.suite.getHooks(name);
function next(i){
// 3. grab current hook
var hook = hooks[i];
// 4. executed all hooks under name x for suite
if (!hook) fn()
Runner.prototype.runSuite = function (suite, fn) {
this.emit(EVENT_SUITE_BEGIN, (this.suite = suite))
function done(errSuite) {
// 6. run all afterAll hooks
self.hook(HOOK_TYPE_AFTER_ALL, () => {
self.emit(EVENT_SUITE_END, suite);
fn(errSuite);
});
}
Runner.prototype.run = function(fn) {
var self = this
var rootSuite = this.suite
fn = fn || function() {}
function start() {
self.started = true
self.emit(Runner.constants.EVENT_RUN_BEGIN)
self.runSuite(rootSuite, function() {
self.emit(Runner.constants.EVENT_RUN_END)
Base.prototype.epilogue = function() {
var stats = this.stats
Base.consoleLog()
// passes
var fmt =
color("bright pass", " ") +
color("green", " %d passing") +
color("light", " (%s)")