Skip to content

Recipe for testing ES6 modules #447

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

Closed
vadimdemedes opened this issue Jan 17, 2016 · 7 comments
Closed

Recipe for testing ES6 modules #447

vadimdemedes opened this issue Jan 17, 2016 · 7 comments

Comments

@vadimdemedes
Copy link
Contributor

No description provided.

@jamestalmage
Copy link
Contributor

It's kind of covered by the code coverage recipe, but it might be good to have a simpler recipe that didn't include that.

Some stuff from this comment would apply here as well.

@jamestalmage
Copy link
Contributor

See https://github.com/jamestalmage/__ava-0.8-with-babel-6 for a working example

Repository name is a misnomer now - it uses [email protected].

@boutros
Copy link

boutros commented Feb 28, 2016

It would also be great to have a recipe of how to use ava with rollup.

@sotojuan
Copy link
Contributor

@boutros What do you mean? Rollup is a module bundler—surely you aren't bundling AVA for production right?

@boutros
Copy link

boutros commented May 10, 2016

Rollup is a module bundler—surely you aren't bundling AVA for production right?

No, not for production of course. Anyway I solved it with rollup, so my remark can be ignored. If anyone is interested here is the relevant commit: boutros/koblersken@c00e3a0

It's easy to get lost in the javascript build jungle :)

@novemberborn
Copy link
Member

I think we're kinda already covering this. Of course if you use new language features that are supported by your targeted Node.js version you don't need to do anything special. If you need to transpile your source code we've covered that in the Transpiling imported modules section.

I'm closing this issue, but if you have ideas on how to improve the documentation please open a new issue or PR!

@backspaces
Copy link

TL;DR: If you're using Rollup and no babel in your workflow, building a cjs bundle and requiring it in your tests works fine.

Details:
I've just started using ava and ran into the es6 modules problem. But because my repo uses Rollup to a cjs bundle (to be node friendly) I just require that in the test file. Ava is OK with that.

Here's an article on the "modern workflow" idea where Rollup is used to convert a bleeding edge project into any format you'd like:
https://medium.com/@backspaces/es6-modules-part-1-migration-strategy-a48de0b7f112

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

No branches or pull requests

6 participants