Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow babel transpilation of test helper files. #156

Closed
jamestalmage opened this issue Nov 7, 2015 · 14 comments
Closed

Allow babel transpilation of test helper files. #156

jamestalmage opened this issue Nov 7, 2015 · 14 comments
Labels
enhancement new functionality question

Comments

@jamestalmage
Copy link
Contributor

We are doing all this work to ensure babel does not leak into any file but the test file, but there is a downside for "helper" files, etc.

The other option would be to hook require and make them provide some sort of include / exclude glob.

@sindresorhus
Copy link
Member

Why did you close?

@jamestalmage jamestalmage reopened this Nov 8, 2015
@jamestalmage
Copy link
Contributor Author

Didn't mean to.

@sindresorhus
Copy link
Member

I'm open to it, as it would be very nice to be able to use ES2015 stuff in test helper files too. I think a whitelist would be better so we could still make use of the ES2015 import semantics.

@sindresorhus sindresorhus added enhancement new functionality question labels Nov 8, 2015
@SamVerschueren
Copy link
Contributor

Would be very nice indeed! Maybe use something like .es6.js as extension? This way you don't need to update the whitelist.

@jamestalmage
Copy link
Contributor Author

Or just default the whitelist to include test/_*, since the underscore prefix is already set aside to denote helpers.

Or just everything in the test directory? Event test/fixtures/**?

@sindresorhus
Copy link
Member

@jamestalmage I think defaulting the whitelist to test/_* is a good idea, not so sure about the whole test directory, though. I would definitely not want my fixtures implicitly transpiled.

@jamestalmage
Copy link
Contributor Author

Thats my feeling as well.

jamestalmage added a commit to jamestalmage/require-from-string that referenced this issue Nov 10, 2015
@jamestalmage jamestalmage changed the title add test.require() which is equivalent to require with babel hook Allow babel transpilation of test helper files. Nov 10, 2015
@just-boris
Copy link

+1, I want this thing too. But why do you need all that stuff around require-from-string?

Why not just add babel hook using require("babel-core/register");?

@jamestalmage
Copy link
Contributor Author

Because, one goal of this library is not to pollute any of your production code with babel transforms/polyfills (unless you specifically ask it to).

@just-boris
Copy link

But all my source code is written for babel too. Will there an option to transpile files from my src/ folder in addition to test/?

@sparty02
Copy link
Contributor

Because, one goal of this library is not to pollute any of your production code with babel transforms/polyfills (unless you specifically ask it to).

I actually want my source code (non-test) to be transpiled by babel as well..... i.e. I want to be able to import a module that is written in ES6 into my ava test module. Is there a suggested technique for this today? Or is this a pending enhancement?

@sindresorhus
Copy link
Member

@sparty02 Pending enhancement. Definitely something we want to support, but haven't had the chance yet. See #111. Any thoughts there much appreciated.

@sparty02
Copy link
Contributor

@sindresorhus ahh.... thanks for the reference to #111. I'll take a look!

@vadimdemedes
Copy link
Contributor

Closing this issue as it's already implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new functionality question
Projects
None yet
Development

No branches or pull requests

6 participants