-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Probably not compiling with babel: Unexpected import token
#1309
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
Comments
Yes. You've disabled AVA's default transpilation of test files. It's now up to you to make sure your code runs in Node.js. You'll have to make sure to transpile the module syntax in your own Babel config. |
Where? My custom babel config (next/babel) support
This error persists. Why closed issue, since this not resolved? |
I actually get this error, which seems to be some Flow syntax that isn't removed:
In any case, it means AVA transpiled the ESM syntax correctly.
But does it transpile to CJS?
This issue tracker is for AVA itself. Happy to do the occasional support here, and happy to keep discussing, but this is a problem with your Babel setup, not AVA. |
Put those to package.json:
Source: transpiling-sources@AVA @avajs, I would suggest making init more clever so those issues are gone. |
I would like to add that it is very un-intuitive that you must add
In order to get ava working with ESNext source files and the documentation here is very misleading:
Since you must add the snippet from above, which is given at the bottom of the doc. |
@mdvorscak that paragraph does attempt to specify "test and helper files", but I agree it's not entirely clear. Perhaps "files" in the second sentence should be "these files", and we should add a paragraph linking to source compilation section? |
I agree, I created a PR to attempt to clarify this behavior. |
Following discussion of #1309, this PR attempts to clarify the documentation to avoid confusion when first setting up AVA with ESNext source files.
Description
Testings are failing in
Unexpected import token
(probably due to non babel compiling issue)Test Source
initials.js
initials.test.js
Error Message & Stack Trace
Here's a print (Sorry, I have a problem with my term that I can't copy text 😢)
Config
package.json
.babelrc
Note: also tested with
"require": ["babel-register"]
in ava configurationCommand-Line Arguments
Relevant Links
Repo: https://github.com/renatorib/next-jsonplaceholder
Initials test commit: renatorib/next-jph@f5602a1
Environment
The text was updated successfully, but these errors were encountered: