-
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
Precompile helpers #1078
Precompile helpers #1078
Conversation
Good start! This compiles the helpers as if they were test files, right? That seems correct to me. Let's see where that gets us before doing anything else for macros. |
4bc021e
to
476c653
Compare
Yep, exactly.
Yes for sure, that is unrelated to this PR. |
|
||
return new AvaFiles({cwd: this.options.resolveTestsFrom}) | ||
.findTestDependencies() | ||
.map(function (file) { // eslint-disable-line array-callback-return |
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.
Why use .map
if you're not actually going to map anything?
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 was using it as a way to async iterate the items. Is there another bluebird method that does that?
600f1d3
to
b5ace1c
Compare
9303025
to
f0f25b5
Compare
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.
Do we foresee people wanting to disable this behavior?
@@ -705,9 +705,16 @@ function generateTests(prefix, apiCreator) { | |||
test(prefix + 'caching is enabled by default', function (t) { | |||
t.plan(3); | |||
rimraf.sync(path.join(__dirname, 'fixture/caching/node_modules')); | |||
|
|||
var prevCwd = process.cwd(); | |||
process.chdir(path.join(__dirname, 'fixture/caching')); |
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.
Why this change?
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.
Tests are being run from the root, so AVA finds and precompiles helpers and fixtures from the test
folder (e.g. test/fixture/ignored-dirs/helpers/test.js
).
That's why I change the cwd to make it look like the tests are being executed from that dir. I think it's actually what each test should do.
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.
The pkgDir
and resolveTestsFrom
directories can be passed to Api
though. That's how its meant to be used, implicit defaults aside. We shouldn't need to change the working directory of the tap
process.
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.
Thanks for the tip!
Specifically transpiling fixtures seems fraught. |
Could you elaborate on this? I don't quite understand the reasoning. |
Helpers should contain logic to make it easier to write test. Fixtures contain all sorts of files that relate to your test. If you're testing a Babel plugin you may write |
@vdemedes What's your use-case for transpiling fixtures? I'm leaning towards @novemberborn's argument. |
My thinking was that everything that resides under However, @novemberborn's reasoning about fixtures relation to tests does make sense to me now. I will correct this PR and the one in |
f0f25b5
to
fe3eec1
Compare
8610723
to
4acb78f
Compare
fe3eec1
to
187b0a6
Compare
w/r/t #1049, I've just installed this branch and ran against an external macro, and it did not appear to resolve the issue that |
@Snugug only files with names starting with |
187b0a6
to
3e8523a
Compare
Code looks good to me, but needs to be added to the readme. |
3e8523a
to
c3fe5ec
Compare
Added a small note to readme: https://github.com/avajs/ava/pull/1078/files#diff-0730bb7c2e8f9ea2438b52e419dd86c9R738. |
Yay! This one is going to be super useful 💃 Thanks for finishing this up Vadim 👌 |
Fixes #720 and potentially #1049.
Lack of this feature has been bugging me for a long time, glad I've finally found a time to fix it. It's still WIP, need to:
ava-files
to supportfindHelpers()
(currently named asfindTestDependencies()
).As for #1049 (external macros are not precompiled), we could add a special glob for that, like
**/macros/**
to precompile those files as well.