Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Last active September 9, 2016 09:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshuawuyts/b2868a1cb181eb546779 to your computer and use it in GitHub Desktop.
Save yoshuawuyts/b2868a1cb181eb546779 to your computer and use it in GitHub Desktop.
jasmine / mocha / jest to tape regex
#!/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