Skip to content

Commit

Permalink
Allow jest script to run on individual files
Browse files Browse the repository at this point in the history
This allows the jest test script for the enterprise_search plugin
to run on files, and well as directories.

Previously, a trailing slash was always appended, whether it was
a file name, or a directory. It now maintains whatever a user originally
inputted.
  • Loading branch information
JasonStoltz committed Apr 8, 2021
1 parent 5d54e29 commit 5b82af6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x-pack/plugins/enterprise_search/jest.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#! /bin/bash

# Whether to run Jest on the entire enterprise_search plugin or a specific component/folder

FOLDER="${1:-all}"
if [[ $FOLDER && $FOLDER != "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 [[ "$FOLDER" == *".ts"* ]]; then
PATH_WITHOUT_EXTENSION=${1%%.*}
FOLDER="${FOLDER} --collectCoverageFrom='<rootDir>/x-pack/plugins/enterprise_search/${PATH_WITHOUT_EXTENSION}.{ts,tsx}'"
# If this is a folder
else
FOLDER=${FOLDER%/} # Strip any trailing slash
FOLDER="${FOLDER}/ --collectCoverageFrom='<rootDir>/x-pack/plugins/enterprise_search/${FOLDER}/**/*.{ts,tsx}'"
fi
else
FOLDER=''
fi
Expand Down

0 comments on commit 5b82af6

Please sign in to comment.