Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Improved watching with chokidar #3980
Improved watching with chokidar #3980
Changes from all commits
5d746bb
0e2ee09
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Something is wrong with
loadOptions()
in "cli/options". I have to check the camel-case option of yargs-parser.When I use
--watch-files <path>
the result is - as it should be - anarray
, when I use--watchFiles <path>
it's astring
.Inputs of
watchFiles
via CLI plus config files are not combined correctly this way.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.
Test case:
--watchFiles ./path1 --watchFiles ./path2
.mocharc.yml
:watchFiles: ['./path3']
current result:
{watchFiles: [ "./path1", "./path2"]
Makes sense, since the type of
watchFiles
isundefined
, notarray
.Setting
camel-case-expansion
totrue
(in "cli/options"), it's still wrong:result:
{watch-files: [ "./path1", "./path2"], {watchFiles: [ "./path1", "./path2"]}
This output seems to be a yargs-parser bug, since an
array
typed option should combine the result.When I use
--watch-files
instead of--watchFiles
the output is correct:result:
{watch-files: [ "./path1", "./path2, "./path3"]}
So the result is due to our camel-case settings and also due to a yargs-parser bug. I don't want to set a quick shot. Do you have an idea, otherwise let's go on and take care of this later.
see: yargs-parser
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.
Unfortunately I don’t. I’m not familiar with yargs’ configuration loading.
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 will open a separate issue for this parsing issue.
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.
Even for the first run - on the
ready
event - we reset everything, right?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.
Yes. This is not ideal but it avoids special casing the initial run.
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 the common behavior of a watch functionality to abort the tests, instead of waiting for the test end and then restarting?
Out of topic: I don't trust
runner.abort()
. I doubt that the hook pattern is correct and allafterEach
/after
hooks run for correct tear-down. This is prone to errors.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.
This is the same behavior as before. I think it makes sense to abort the tests when a file changes. If you usually want to get quick feedback when your code changes.
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 see the meaning of this. We had a similar situation with
grep
in another PR.ui
is set by theMocha
constructor and is read once when Mocha is launched. There is no need to reset it here again.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 added a comment in 4e7c743 that explains why we need it. If you look at the code of
mocha.ui()
you see that it registers some hook onmocha.suite
that is makes the global DSL (e.g.describe
) work. If we omit the call tomocha.ui()
the new test suites will never be registered.