-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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: Add option to follow symlinks found by glob patterns #3584
Comments
I'm not sure if we specify a minimum Windows OS version, so someone else will need to interpret its impact. Unsure whether this was done intentionally to "return the same results" on all platforms. See NTFS symlinks. |
fast-glob is support so i think can replace |
Maybe this should be added as an additional flag rather than the default behavior? I added the "future" tag since I believe it might be a good idea to land yargs first (#3556) (feel free to disagree) |
Agree it would probably not be a great idea to make this the default behavior. @mbeerta-factset Are there any workarounds at present time? |
unfortunately not, but i had the same thoughts of making this switchable. Might be reusing the --preserve-symlinks option a viable approach (although it is also passed to the node runtime)? |
Hi, I would love to do this issue if it isn't fixed yet. |
I'm posting here my current workaround (via monkeypatching) for this: mocha-monkeypatched.js: // monkeypatching libs
var Module = require('module');
var originalRequire = Module.prototype.require;
let globMonkeyPatched = false;
Module.prototype.require = function () {
const original = originalRequire.apply(this, arguments);
if (!globMonkeyPatched && "glob" === arguments[0]) {
// BUG #1: cf. https://github.com/mochajs/mocha/issues/3584
// mocha doesn't detect test files in linked dirs
var originalSync = original.sync;
original.sync = function () {
const options = arguments[1];
options.follow = true;
return originalSync.apply(this, arguments);
}
globMonkeyPatched = true;
}
return original;
};
// BUG #2: cf. https://github.com/paulmillr/chokidar/issues/987
// mocha cannot watch multiple file extensions; hence this workaround
process.argv.push("-w", "--watch-files", ".");
// INIT_CWD only exists when launched w/ npm run ...; if needed to run as stand alone, a solution around process.argv[1] can be built
require(process.env.INIT_CWD + "/node_modules/mocha/bin/_mocha"); package.json:
NOTE: I also discovered another issue regarding linked files, but related to watching. |
👍 that making this the default behavior is too scary of a change, but that as a new option it would be good. |
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
This is related to #1223 where util.lookupFiles does not follow symlinks and this still happens if provided with a glob pattern. The solution would be to add a
{follow: true}
argument to the glob.sync call.Steps to Reproduce
Create a symlink to a directory containing test files, call mocha with a glob to that directory.
Expected behavior: Tests in symlinked folders will be executed
Actual behavior: Tests are ignored
Reproduces how often: every time
Versions
mocha --version
andnode node_modules/.bin/mocha --version
: latestnode --version
:Additional Information
I'm happy to create a pull request, however i'm not familiar with the implications such a change might have.
The text was updated successfully, but these errors were encountered: