-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Added support for babel config under package.json/ava key (Fixes #448) #573
Conversation
By analyzing the blame information on this pull request, we identified @novemberborn, @sotojuan and @ariporad to be potential reviewers |
@@ -97,7 +97,8 @@ var api = new Api(cli.input.length ? cli.input : arrify(conf.files), { | |||
failFast: cli.flags.failFast, | |||
serial: cli.flags.serial, | |||
require: arrify(cli.flags.require), | |||
cacheEnabled: cli.flags.cache !== false | |||
cacheEnabled: cli.flags.cache !== false, | |||
babelConfig: conf.babel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong indentation here.
Good start :) This will need tests and docs too. |
Fixed indentation, added tests, and added docs. |
} | ||
``` | ||
|
||
If you do not specify a "babel" key in your ava configuration, or if you set it to `"default"`, AVA will transpile the test files with AVA's default babel configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this default configuration defined anywhere else in the docs? If not, it should be. Then this should link to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I don't believe it is defined anywhere, but it should be.
Hey @spudly, could you rebase from master to resolve a conflict? Thanks for the great work! |
@vdemedes It's been rebased. |
Great, I think it's good to go! |
}; | ||
|
||
if (!babelConfig || babelConfig === 'default') { | ||
return objectAssign({}, baseOptions, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the empty object here, baseOptions
is already fresh so it's safe to mix other properties into it.
Haven't looked at the tests yet, sorry. Been staring at AVA issues all day :) Could you follow up on #448 (comment)? Looking really good though, nice work. |
} | ||
|
||
if (babelConfig === 'inherit') { | ||
return objectAssign({}, baseOptions, {babelrc: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, we will want to ensure powerAssert
is added as a plugin regardless.
The tests exercise Right now @spudly thanks for the hard work on this. It's solving so many of our issues! |
Pushed a new commit & rebased. I believe I've addressed all of the concerns that were discussed, with the exception of the |
Can anyone help explain why these 44 tests are failing? https://travis-ci.org/sindresorhus/ava/jobs/112878667 They're unrelated to my changes - the master branch of AVA fails the same tests. These tests were passing yesterday, but today they fail. Perhaps one of the dependencies had a release that broke with semver? |
Might be related to babel 6.6 release yesterday. I noticed that your previous build used 6.5.2 while this one used 6.6. |
test('creation with new', function (t) { | ||
var tempDir = uniqueTempDir(); | ||
var precompiler = new CachingPrecompiler(tempDir); | ||
var precompiler = new CachingPrecompiler(tempDir, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should pass 'default'
here (and below).
Failures may be similar to MoOx/phenomic#229 (or may not) |
@spudly did a fresh checkout and install, |
@spudly ah! The failing tests use I still think using the default config in |
My bad, I must have made a mistake when I checked out master and ran the tests again yesterday. Did it again this morning and the tests are passing. I'll fix this very soon. |
I'm stumped guys. If I do the following, all tests pass as expected. git clone https://github.com/sindresorhus/ava.git
cd ava
git reset --hard 58e1c561296a409a9557ceb1c7684685404c4278
npm install
npm test But if I do this, 44 tests fail: git clone https://github.com/spudly/ava.git
cd ava
git reset --hard 58e1c561296a409a9557ceb1c7684685404c4278
npm install
npm test Both repos are being reset to the same initial commit (the one before any of my changes), so there should be absolutely no difference between the two, right? |
I'm running both of those series of commands now. I'll let you know what I get |
Everything passed for me for both of those. Sounds like an environment issue... |
Nevermind. running npm install fixed that issue. Still curious though, why are those return statements there? |
made requested changes and rebased again. |
They're shorthand for exiting the CLI. |
@spudly what's the reason for adding the |
That dependency was added by @jamestalmage in the |
I guess "outside" commits shouldn't be in this PR, should they? |
Ah! @vdemedes are you in Gitter at the moment? Let's see about landing the integration test plugin in |
Landed in a03f826 yay! (Messed up the commit so it didn't close automatically… oops) |
Awesome work, thanks @spudly! |
Nice! Thanks for the help everyone! |
Yay! Nice work @spudly 💃 |
Hooray! 🎉🎉🎉 |
👏 👏 For those wondering, it appears as though this hasn't yet been published to npm — however a |
Can we get a cli option for that as well? I prefer specifying it there instead of adding a config in the package.json |
Please raise an issue. |
Here's an initial commit that allows package owners to specify a babel config for tests under the package.json/ava key.
This conforms to the proposal in the following comment: #448 (comment)
I chose not to implement an extends key discussed in the thread because 1) it adds to the complexity, 2) I personally don't need it, and 3) how to solve that request is still somewhat unresolved. If needed, someone can add that later in another pull request.
Let me know what you think. I'm a little unsure about whether my method for obtaining babelConfig is the best one.