Skip to content

Instantly share code, notes, and snippets.

@fpirsch
fpirsch / smallest-test-framework.js
Last active August 28, 2021 21:03
The smallest test framework
const test = exports.test = (label, cb) => (test.$list || (test.$list = [])).push({ label, cb })
exports.beforeEach = cb => test.$beforeEach = cb
setImmediate(() => test.$list.forEach(async ({ label, cb }) => console.log(label, await cb(test.$beforeEach?.()) || '\u001B[32m✔\u001B[39m')))
test.skip = (label, cb) => console.log(label, '\u001B[91m✗ SKIPPED\u001B[39m')
test.todo = (label, cb) => console.log(label, '\u001B[91m✗ TODO\u001B[39m')
test.only = (label, cb) => (test.$list = [{ label, cb }]).push = () => {}
@fpirsch
fpirsch / toHaveClass.js
Created September 30, 2014 14:02
Protractor/jasmine toHaveClass custom matcher
/**
* Custom "toHaveClass" matcher.
*
* Based on https://gist.github.com/darthwade/9305669
* and https://gist.github.com/elgalu/94284ec0ac3e8a590507
*
* usage :
* require('./toHaveClass.js');
* ...
* expect($('html')).toHaveClass('wf-active');