generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: default cacheDirectory to TEST_TMPDIR (#231)
* feat: default cacheDirectory to TEST_TMPDIR See #230 * use dedicated jest cache folder under TEST_TMPDIR
- Loading branch information
1 parent
308617d
commit 428b2da
Showing
5 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit -o nounset -o pipefail | ||
|
||
# Jest default is os.tmpdir()/jest_<uid> | ||
TEST_TMPDIR=$(mktemp -d)/jest_test_tmpdir | ||
|
||
# Case 13: jest_test uses TEST_TMPDIR | ||
rm -rf "$TEST_TMPDIR" | ||
bazel test //jest/tests:case13 --nocache_test_results --test_tmpdir=$TEST_TMPDIR | ||
|
||
# Locate the cache folder under TEST_TMPDIR | ||
JEST_CACHE_NAME="jest_cache" | ||
JEST_CACHE_DIR=$(find "$TEST_TMPDIR" -type d -name "$JEST_CACHE_NAME" -print -quit) | ||
|
||
# Check that the cache folder exists | ||
if [ -z "$JEST_CACHE_DIR" ]; then | ||
echo "Error: '$JEST_CACHE_NAME' folder not found below '$TEST_TMPDIR'" | ||
exit 1 | ||
fi | ||
|
||
# Check that the folder was used for the cache | ||
if [ -z "$(ls -A "$JEST_CACHE_DIR")" ]; then | ||
echo "Error: '$JEST_CACHE_NAME' folder at '$JEST_CACHE_DIR' is empty" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
reporters: ["default"], | ||
testEnvironment: "node", | ||
testMatch: ["**/*.test.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test("it should work", () => { | ||
expect(1).toBe(1); | ||
}); |