wavded / babel-tape-runner

Babel + Tape runner for your ESNext code
134 stars 16 forks source link

Why does this lib require babel-polyfill? #15

Open olegskl opened 8 years ago

olegskl commented 8 years ago

I'm a maintainer of gulp-stylelint which uses babel-tape-runner to run tests. The tests are run on Travis in Node v0.12, v4, and v5.

One day I've added Object.assign to my code, oblivious to the fact that it doesn't exist in Node v0.12. The tests didn't fail, so I published a release and soon received a bug report.

I've looked at the babel-tape-runner code and found this line:

require('babel-polyfill')

Which obviously polyfills Object.assign, but I'm not sure why babel-tape-runner itself needs it. There's nothing to polyfill in babel-tape-runner.

The problem is that polyfills are also applied to the code under test. Is it possible to remove them?

wavded commented 8 years ago

Reference: https://github.com/wavded/babel-tape-runner/issues/7

Historically, Babel 5 had it included by default in their register. No way to include it in the .babelrc (still?) so if you wanted it, you'd have to either include it in every test file or in the first test that is "required".

See your point though, perhaps a flag to turn it off?

olegskl commented 8 years ago

Perhaps, instead of a flag, it would be an interesting idea to add a --require option similar to what mocha does. So we could do:

babel-tape-runner test/*.js --require babel-polyfill
wavded commented 8 years ago

I like that. Care to do a PR? That would be breaking change but feels like a better API to me.

olegskl commented 8 years ago

After forking and looking at the code more closely I came to a conclusion that this library is not needed at all and can safely be deprecated in favor of using vanilla tape which already has the require flag.

My scenario calls for:

tape -r babel-register test/*.spec.js

People using async/await in their tests might be interested in:

tape -r babel-register -r babel-polyfill test/*.spec.js
snuggs commented 8 years ago

@olegskl how is this coming along? Can you submit a PR? I concur it isn't required anymore. /cc @wavded

olegskl commented 8 years ago

This is not required anymore. Tape can work with babel out of the box.

wavded commented 8 years ago

Yep, @olegskl is right. This lib is not needed anymore. It would be preferred to use the tape lib directly.