Last active
November 2, 2021 23:04
-
-
Save LeaVerou/7cd767a624a9f2fd98fb0473969dd180 to your computer and use it in GitHub Desktop.
Shim to migrate Tape tests to Mocha tests
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
// 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