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

Support for --file option #222

Closed
sstarnaud opened this issue Apr 3, 2019 · 14 comments
Closed

Support for --file option #222

sstarnaud opened this issue Apr 3, 2019 · 14 comments

Comments

@sstarnaud
Copy link

Is it possible to add support for the mocha '--file' option that would help in executing root level hooks?

@1999
Copy link
Collaborator

1999 commented Apr 10, 2019

Sure, why not. I guess the only important thing to notice is that this --file thing will be executed for all suites, i.e. if you rely on some "state" from this --file in all your tests, this will not work with mocha-parallel-tests

@sstarnaud
Copy link
Author

sstarnaud commented Apr 10, 2019

@1999 Maybe this won't work for what I'm trying to achieve. I'm trying to have a 1 time 'before' that runs before all test executions and then a 1 time 'after' that runs after all test executions are complete. This works with the '--file' option in mocha but when I try this with mocha-parallel-tests it throws this "error: unknown option `--test'".

Is this 1 time before/after possible with mocha-parallel-tests?

@1999
Copy link
Collaborator

1999 commented Apr 12, 2019

Not really unfortunately

@nekiscz
Copy link

nekiscz commented Jun 13, 2019

Do you have some guidelines or how to for contributors?

@1999
Copy link
Collaborator

1999 commented Jun 13, 2019

Probably not. The project right now is not that complicated. Linting is preconfigured and editorconfig should help you start writing the code. For all pull requests, it's great to add some test - they are in "test" directory. Other than that, feel free to reach me out and ask for help.

@emmakun
Copy link

emmakun commented Jun 24, 2019

The --file option would be a nice adding, I have an issue to load global async hooks.
I know this would not be the perfect solution, since it will be called for each process, but will still be an improvement that would let setup and teardown things on a process/suite basis.

@misko-frame
Copy link

+1

@favna
Copy link
Contributor

favna commented Sep 12, 2019

Really need this. In our old frontend we're still using Mocha (in new frontends we moved to Jest) and running tests there can take quite a bit of time. Running them in parallel would be a great thing but alas, we need a file setup for the tests to actually run as it requires some libraries to have been spun up that cannot be included with --require.

I'm open to making the PR for this but I'm not exactly sure what the flow is after looking through the code, that said I'll give it a shot and see where I get.

@1999
Copy link
Collaborator

1999 commented Sep 14, 2019

@favna that's the spirit :) The flow is pretty easy - you create a PR which contains a test, we review it together and merge. The tests are in "test" folder, see delay option support test for example.

@favna
Copy link
Contributor

favna commented Sep 14, 2019

@1999 I gave it a shot but I can't quite figure out tests. Maybe you could have a look? Here is the compare of the changes I've made so far: master...Favna:feat/file_option, based on this branch: https://github.com/Favna/mocha-parallel-tests/tree/feat/file_option.

For some reason adding this code also has many other tests fail, but some pre-existing tests are already failing on a clean version of master. Not sure if that's just because I'm on Windows? Do you guys use a Unix system to develop? Edit: as per partial example this is what I mean with tests on master failing on windows: https://hasteb.in/roriheyi.yaml

@1999
Copy link
Collaborator

1999 commented Sep 16, 2019

Not sure if that's just because I'm on Windows

That's the reason: mocha-parallel-tests doesn't work well on Windows: #254. If you can use Linux/Mac to run your tests that would be easier for now. Also, could you please raise a PR so we can continue the convo there?

@favna
Copy link
Contributor

favna commented Sep 28, 2019

Took quite my time but I've been busy. Just fixed the tests using my Macbook and created PR #267

favna added a commit to favna/mocha-parallel-tests that referenced this issue Sep 28, 2019
@DanMossa
Copy link

DanMossa commented Feb 8, 2020

Any progress on this? ;D

@favna
Copy link
Contributor

favna commented Feb 8, 2020

Pretty much only my PR #267 @DanMossa. I haven't really made time to look into why tests are flaky and I haven't been much motivated either since I have a strong preference for the Jest framework myself these days. My only interest in Mocha at the time lay in a single legacy app we still had at work but we've pretty much deprecated that app now as well.

1999 pushed a commit that referenced this issue Feb 8, 2020
@1999 1999 closed this as completed in aa1f834 Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants