From 7809e9470e58df0b892e232819c98737b08705bc Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <cwillisf@media.mit.edu> Date: Tue, 19 Sep 2017 23:53:41 +0100 Subject: [PATCH] Allow either slash in path passed to Jest 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. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 298217f51..c50b449d3 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "i18n:src": "babel src > tmp.js && rimraf tmp.js && ./scripts/build-i18n-source.js ./translations/messages/ ./translations/", "lint": "eslint . --ext .js,.jsx", "start": "npm run i18n:msgs && webpack-dev-server", - "unit-test": "jest test/unit", - "integration-test": "npm run build && jest --runInBand test/integration", + "unit-test": "jest test[\\\\/]unit", + "integration-test": "jest --runInBand test[\\\\/]integration", "test": "npm run lint && npm run unit-test && npm run integration-test", "watch": "webpack --progress --colors --watch" }, -- GitLab