-
Notifications
You must be signed in to change notification settings - Fork 27
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
[Feature] Pass through arguments into Mocha #34
Comments
I agree with this approach in general, we should stop trying to re-implement mocha features, but the question is how to do it :) |
Sorry for the lack of follow up on this. I want to work on this but I haven't had the time to put into it. Hoping to get to it in the new year. |
@JamesMcMahon No problems, this is open source, we all are volunteers, take your time! |
Jack's PR for Mocha, mochajs/mocha#4122 seems like it would be helpful here. |
A possible workaround could be to add a parameter to mochapack That way you should be able to allow your users to utilize the full power of mocha, without having to wrap each parameter. It still feels a bit like a workaround to me, but perhaps it's good enough. |
Oh didn't notice :/ that seems to be deprecated :( Perhaps the config file will do the trick: https://mochajs.org/#-config-path |
I think the snag here though is that if a user points to a config file then they still might want to override the configured settings for a one-off run of their test script. Hopefully I can get something rigged up to get as close to parity with Mocha as possible by end of next week. Since a few of our projects at work are relying on this, I am pretty much going to be focused on it until it's up to snuff. Barring acceptance of mochajs/mocha#4122, the best option here that I can see is to split the Mocha specific options into their own file to at least make updating them more painless until that PR does get merged in. Once it does get merged we just point to that and can delete the file out. |
@larixer and @JamesMcMahon I am tackling this issue this week ✊🏼 Jumping into it, there are a couple of things I wanted to get some second/third opinions on: Short Version
Long Version
|
Generally, anything that improve compatibility with future Mocha versions and reduce maintenance burden should be positive. |
Followup for previous comment:
Jumped ship on my previous stab at this (forgot what the hell I was doing on it). However, making some huge progress on this and pretty excited about it: https://github.com/Jack-Barry/mochapack/tree/mocha-cli-args Building out the replacement tooling on the side so that it doesn't interfere with too many existing files. Added a temporary script as Modularized Args ParsingA new implementation of parsedArgs = {
mocha: {},
webpack: {},
mochapack: {}
} One Place for Args-to-Options TranslationFunctionality for translating the parsed arguments into an object that can be used to initialize Mochapack is split into its own set of functions under mochaPackOptions = {
mocha: {
cli: {},
constructor: {},
},
webpack: {
config: '',
env: '',
// ...
},
mochapack: {}
} where The Really Exciting Part🎉 A new Next StepsThere's still plenty of work to do to get this wrapped up, but overall I think some of these changes will make extending the functionality in other areas of Mochapack a lot more straightforward in the future as well. A lot of gigantic functions can be broken down into smaller chunks that are easier to reason about and build on top of. I'll be trying to get the following done over the next few days:
|
@Jack-Barry Excellent progress! I like how your approach gives structure to the options parsing and utilizing by different tools. Thanks! |
@JamesMcMahon Would you consider this resolved as per the finalization of #63? |
Describe the user story
Why
As user of mochapack
I want be able to use all the command line features of mocha, both currently and as mocha is updated
So that I don't have to wait on mochapack to be updated
Acceptance Criteria
Describe the solution you'd like
While working on #30 it became clear to me that while it would be easy to add additional mocha options to the cli, it feels sub-optimal to have to essentially write the same code and tests for each option.
I'd like to refactor and add to the internals of mochapack to support a passthrough of args to mocha. That way we don't need to scramble to support additional args as the mocha people add them.
Describe the drawbacks of your solution
Not sure how this would effect the programmatic API of the mochapack (or if we care about that as a feature). There is a possibility of breaking changes to that API, but as far as I can tell the CLI options are 1 for 1.
I also think it's possible to implement the changes in a way that the API does not break, with possible deprecation markers being added to certain methods that we want to remove in the future.
Describe alternatives you've considered
Looking for feedback on this thread of alternative solutions.
Additional context
This make sense to me given the current requested features from both this project and
mocha-webpack
. I also think this could result in a simpler code base as right now mochapack is deeply concerned with the particulars of mocha's options. I think we should get out of the business of trying to re-implement mocha features.I am willing to work on this. It feels like a decent chunk of work, though I am admittedly new the project, so my estimate may be off. I wanted to get buy in before embarking on a PR.
Command line option requests:
--globals
zinserjan/mocha-webpack#192Probably missed a few, but you get the gist 😆
The text was updated successfully, but these errors were encountered: