-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Allow jest script to run on individual files (#96589
) (#96852) Co-authored-by: Jason Stoltzfus <[email protected]>
- Loading branch information
1 parent
3129413
commit 3afc091
Showing
2 changed files
with
17 additions
and
7 deletions.
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
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 |
---|---|---|
@@ -1,18 +1,26 @@ | ||
#! /bin/bash | ||
|
||
# Whether to run Jest on the entire enterprise_search plugin or a specific component/folder | ||
FOLDER="${1:-all}" | ||
if [[ $FOLDER && $FOLDER != "all" ]] | ||
|
||
TARGET="${1:-all}" | ||
if [[ $TARGET && $TARGET != "all" ]] | ||
then | ||
FOLDER=${FOLDER%/} # Strip any trailing slash | ||
FOLDER="${FOLDER}/ --collectCoverageFrom='<rootDir>/x-pack/plugins/enterprise_search/${FOLDER}/**/*.{ts,tsx}'" | ||
# If this is a file | ||
if [[ "$TARGET" == *".ts"* ]]; then | ||
PATH_WITHOUT_EXTENSION=${1%%.*} | ||
TARGET="${TARGET} --collectCoverageFrom='<rootDir>/x-pack/plugins/enterprise_search/${PATH_WITHOUT_EXTENSION}.{ts,tsx}'" | ||
# If this is a folder | ||
else | ||
TARGET=${TARGET%/} # Strip any trailing slash | ||
TARGET="${TARGET}/ --collectCoverageFrom='<rootDir>/x-pack/plugins/enterprise_search/${TARGET}/**/*.{ts,tsx}'" | ||
fi | ||
else | ||
FOLDER='' | ||
TARGET='' | ||
fi | ||
|
||
# Pass all remaining arguments (e.g., ...rest) from the 2nd arg onwards | ||
# as an open-ended string. Appends onto to the end the Jest CLI command | ||
# @see https://jestjs.io/docs/en/cli#options | ||
ARGS="${*:2}" | ||
|
||
yarn test:jest $FOLDER $ARGS | ||
yarn test:jest $TARGET $ARGS |