Last active
September 9, 2016 09:19
-
-
Save yoshuawuyts/b2868a1cb181eb546779 to your computer and use it in GitHub Desktop.
jasmine / mocha / jest to tape regex
This file contains hidden or 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
#!/bin/sh | |
transform () { | |
sed 's/^describe/test/' \ | |
| sed "1 i import test from 'tape'" \ | |
| sed '/\sit/a t\.plan(1)' \ | |
| sed 's/^\(\s*\)describe/\1t\.test/' \ | |
| sed 's/\(\s*\)it(/\1t\.test(/' \ | |
| sed 's/\, function[\s]*()/\, function (t)/' \ | |
| sed 's/expect(/t.equal(/' \ | |
| sed 's/)\.toEqual(/, /' \ | |
| sed 's/)\.toBe(/, /' | |
} | |
transform < "$1" | sponge "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment