Skip to content

Instantly share code, notes, and snippets.

@LeaVerou
Last active November 2, 2021 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeaVerou/7cd767a624a9f2fd98fb0473969dd180 to your computer and use it in GitHub Desktop.
Save LeaVerou/7cd767a624a9f2fd98fb0473969dd180 to your computer and use it in GitHub Desktop.
Shim to migrate Tape tests to Mocha tests
// Migrate Tape tests to Chai tets (used by Mocha)
// This will not get you 100% of the way, but it will get you most of the way there (depending on your tests).
// I mainly only had to rewrite tests that used subtests (`t.test()`): For those, I used `describe` for the outer test, and converted `t.test()` to `test()`
import { assert } from '@esm-bundle/chai';
assert.ok = assert.isOk.bind(assert);
assert.pass = assert.isOk.bind(assert, true);
assert.end = () => {}; // no-op
assert.plan = () => {}; // no-op, doesn't seem to be needed with WTR
let test = function(title, fn) {
return it.call(this, title, () => {
fn.call(this, assert);
});
};
export default test;
export { assert };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment