Skip to content
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

None files match should not throw #2380

Closed
tianjianchn opened this issue Jul 19, 2016 · 3 comments
Closed

None files match should not throw #2380

tianjianchn opened this issue Jul 19, 2016 · 3 comments
Labels
status: waiting for author waiting on response from OP - more information needed

Comments

@tianjianchn
Copy link

When none files match the pattern test/**/*.test.js, call mocha with --opts will throw Error: cannot resolve path (or pattern) 'test/**/*.test.js'. The pattern for glob is ok, even though its return files.length = 0. So I think this case should not be considered as an error.
The code in mocha is:

      files = glob.sync(path);
      if (!files.length) {
        throw new Error("cannot resolve path (or pattern) '" + path + "'");
      }
@boneskull boneskull added the status: waiting for author waiting on response from OP - more information needed label Jul 20, 2016
@boneskull
Copy link
Member

@kiliwalk Thanks for the suggestion. Can you explain why this is problematic? It seems like reasonable behavior to me, and is exhibited by other test runners (if you would consider the mocha executable to be a "test runner").

@tianjianchn
Copy link
Author

I'm now creating a toolset to use mocha to test. When I tested it with none-match case, the throw error made me confused. I thought maybe my pattern was wrong format till I found the code.
I agree that throw error is reasonable as you said, but how about to change the error description? Like Cannot find any files to match the pattern + path, or something like this?

@boneskull
Copy link
Member

@kiliwalk Would accept PRs for any and all improvements to error messaging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author waiting on response from OP - more information needed
Projects
None yet
Development

No branches or pull requests

2 participants