Skip to content
Snippets Groups Projects
  • Christopher Willis-Ford's avatar
    7809e947
    Allow either slash in path passed to Jest · 7809e947
    Christopher Willis-Ford authored
    Jest takes an argument to specify which tests should be run. The
    argument is treated as a regular expression and matched against the
    filenames of potential tests. Unfortunately Jest does not normalize path
    separators to forward slashes when running this comparison, so (for
    example) `tests/unit` doesn't match anything on Windows.
    
    This change replaces the forward slash in Jest arguments with `[\\\\/]`.
    
    Ideally, that should just be `[\\/]` -- escaping the backslash so that
    it survives NPM's JSON parsing -- but unfortunately the Windows version
    of Jest parses its command line arguments differently from other
    platforms. Specifically, the Windows version of Jest processes
    backslashes one extra time. Fortunately having a redundant backslash is
    OK on Mac and Linux, so `[\\\\/]` ends up working on all platforms.
    7809e947
    History
    Allow either slash in path passed to Jest
    Christopher Willis-Ford authored
    Jest takes an argument to specify which tests should be run. The
    argument is treated as a regular expression and matched against the
    filenames of potential tests. Unfortunately Jest does not normalize path
    separators to forward slashes when running this comparison, so (for
    example) `tests/unit` doesn't match anything on Windows.
    
    This change replaces the forward slash in Jest arguments with `[\\\\/]`.
    
    Ideally, that should just be `[\\/]` -- escaping the backslash so that
    it survives NPM's JSON parsing -- but unfortunately the Windows version
    of Jest parses its command line arguments differently from other
    platforms. Specifically, the Windows version of Jest processes
    backslashes one extra time. Fortunately having a redundant backslash is
    OK on Mac and Linux, so `[\\\\/]` ends up working on all platforms.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
This project manages its dependencies using npm. Learn more