chai-fs icon indicating copy to clipboard operation
chai-fs copied to clipboard

Document that / is used instead of path.sep and allow using path.sep

Open mbargiel opened this issue 6 years ago • 0 comments

The comment on https://github.com/chaijs/chai-fs/blob/e59d5523eed89c6d9f6cee54265e9fc5aad37cb1/lib/assertions/directory_content.js#L74 claims that / is hard-coded to make tests portable. (In our case, this actually makes our tests less portable as we use path.join in our tests to get behavior closer to the OS we're running on.)

This choice should be documented (it was a surprise when it failed in Windows tests during CI).

Bonus points: making this overridable with a configuration option somewhere (e.g. usePathSep or something to that effect, whose default value would result in the current behavior) would ensure existing tests still work, but people writing code intended for multiple OSes can write tests more easily if they choose to use path.join in their test code.

mbargiel avatar Oct 18 '18 14:10 mbargiel