jasmine / jasmine-npm

A jasmine runner for node projects.
MIT License
376 stars 145 forks source link

Project base dirs containing special Glob syntax don't work #206

Closed MumblingFumbler closed 1 year ago

MumblingFumbler commented 1 year ago

Feature Proposal

Support square brackets ('[' and ']') and all possible Windows path characters in Jasmine The project path [Jasmine Sandbox] is a legitimate windows folder name. But if [Jasmine Sandbox] appears in a project path, jasmine will not be able to find spec files, and jasmine reports No specs found Finished in 0.001 seconds Incomplete: No specs found even if there are specs in the specs folder. If you aren't going to fix it, at least report an error indicating that jasmine doesn't like the path, and what it doesn't like about it. Are legitimate and invalid path characters documented anywhere? It looks like spaces in paths are handled correctly.

Context

I wouldn't have had to spend several hours trying to figure out why my spec files were not being found.

Example

No response

Other Information

No response

sgravrock commented 1 year ago

It sounds to me like you think that Jasmine intentionally filters out paths containing square brackets, and that this means that Windows paths aren't supported.

Here's what actually happened: You ran into an obscure bug involving the interaction between jasmine, glob, and certain specific sequences of characters in the project base directory. The bug has been there since the very first commit of the jasmine package's code back in 2014, and it's not Windows specific. Nobody knew about it until now, or at least nobody reported it.

The issue is that fields like spec_files are evaluated by concatenting them with the project base directory and passing the result to glob. As a result, project paths containing special glob syntax don't work. In this case, the sequence [Jasmine Sandbox] gets evaluated as a regex style character class. Since the literal string [Jasmine Sandbox] doesn't match the character class [Jasmine Sandbox], the glob result doesn't include any files. This could probably be fixed by passing the project base directory to glob separately rather than concatenating it.