question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Pass through arguments into Mocha

See original GitHub issue
  • I’d be willing to implement this feature

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

Scenario: 
Given a command line option that mochapack doesn't currently support (ie, `--forbid-pending` or `--file`)
When I add that option when I run mochapack, `npx mochapack --forbid-pending *.test.js`
Then I see mochapack behavior in the same way as the option would behavior in mocha

Describe the solution you’d like

While working on https://github.com/sysgears/mochapack/pull/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:

Probably missed a few, but you get the gist 😆

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
larixercommented, Apr 13, 2020

@Jack-Barry

  1. Probably yes
  2. Unsure
  3. No apparent reason, lets go constructor way if its simpler and better

Generally, anything that improve compatibility with future Mocha versions and reduce maintenance burden should be positive.

0reactions
Jack-Barrycommented, May 6, 2020

@JamesMcMahon Would you consider this resolved as per the finalization of #63?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass arguments to program through mocha - node.js
mocha is going to think those are paths to test files/directories. Maybe use environment variables or a configuration file instead of ...
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
simple, flexible, fun. Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun....
Read more >
Command-line usage - mocha - w3resource
By default, Mocha attempts to trap uncaught exceptions thrown from running tests and reports these as test failures. You should use --allow- ...
Read more >
Write Good Tests with Mocha Cheatsheet - Codecademy
In Mocha, the it() function is used to execute individual tests. It accepts a string to describe the test and a callback function...
Read more >
Mocha - API Manual
Mocha is a feature-rich JavaScript test framework running on Node.js and the browser, making asynchronous testing simple and fun. Mocha tests run serially, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found