mochajs / mocha

☕️ simple, flexible, fun javascript test framework for node.js & the browser
https://mochajs.org
MIT License
22.6k stars 3.01k forks source link

Add the ability to list files to be tested #3581

Closed plroebuck closed 10 months ago

plroebuck commented 5 years ago

Description

Output files to be tested (in load order) with the debug package using the namespace 'mocha:files' in "bin/_mocha" file.

var debug = require('debug')('mocha:files');    // immediately before L16
...
debug('files:', files);    // L575

Additional Information

Test as follows:

  1. Using default "test" directory
    $ DEBUG='mocha:files' mocha --recursive
  2. Using extended glob (results should be same as case 1)
    $ DEBUG='mocha:files' mocha 'test/**/*.js'
  3. Using default "test" directory, excluding files in subdir "setup"
    $ DEBUG='mocha:files' mocha --exclude 'test/setup/**' --recursive
  4. Using extended glob, excluding files in subdir "setup" (results should be same as case 3)
    $ DEBUG='mocha:files' mocha --exclude 'test/setup/**' 'test/**/*.js'
  5. Using default "test" directory, with prepended file "test/setup/init.js"
    $ DEBUG='mocha:files' mocha --file test/setup/init.js --exclude 'test/setup/**' --recursive
  6. Using extended glob, with prepended file "test/setup/init.js" (results should be same as case 5)
    $ DEBUG='mocha:files' mocha --file test/setup/init.js --exclude 'test/setup/**' 'test/**/*.js'
holybubbles commented 5 years ago

Anybody mind if I take this one?

plroebuck commented 5 years ago

Exists in Mocha-6.0 (though hate the namespace) using:

$ DEBUG='mocha:cli:run:helpers' mocha --recursive
holybubbles commented 5 years ago

So should someone close this issue? Since it's already fixed now?

plroebuck commented 5 years ago

I'll leave it open for now and see if I can use a simpler namespace...

boneskull commented 5 years ago

@plroebuck I'm confused; is this intended to be user-facing? If so, DEBUG is sort of a wonky way to do it. It would be cool to see:

  1. A list of all test files
  2. A tree of all test files and user code (stuff not in a node_modules)
  3. A --dry-run which would dump all suites but not run any tests
boneskull commented 5 years ago

Given the cross-cutting concerns that such an implementation would need to touch, I don't think this is a good candidate for a first issue

johnwhelchel commented 5 years ago

This was implemented and closed quite quickly it seems.

Can we re-open this PR?

It seems like something a lot of people would like!

https://github.com/mochajs/mocha/pull/1070

sh3raawii commented 5 years ago

You are welcome https://github.com/sh3raawii/mocha-decaf

JoshuaKGoldberg commented 10 months ago

Fixed by #4640. 🚀