Skip to content

Commit 1b2f314

Browse files
committed
Solved the path check issue fir IsCommonTestFolder
1 parent 23a6abd commit 1b2f314

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

utils.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,14 @@ func IsInTestFolder(path string, testsPath string) bool {
8383
func IsCommonTestFolder(path string) bool {
8484
testPaths := [3]string{"test", "e2e", "__tests__"}
8585

86-
for _, element := range testPaths {
87-
if strings.Contains(path, string(os.PathSeparator)+element) {
86+
for _, testPath := range testPaths {
87+
// Here, we want to do 2 things:
88+
// - Exclude the `testPath` itself, i.e. check for a path that ends e.g. with "/e2e"
89+
// - Exclude any file in it, i.e. check for path that contains e.g. "/e2e/"
90+
testFolderPath := string(os.PathSeparator) + testPath
91+
fileInTestFolderPath := testFolderPath + string(os.PathSeparator)
92+
93+
if strings.HasSuffix(path, testFolderPath) || strings.Contains(path, fileInTestFolderPath) {
8894
if !didPrintDefaultTestFoldersMsg {
8995
log.Info("\tIgnoring common test folders (such as `e2e`)")
9096
didPrintDefaultTestFoldersMsg = true

0 commit comments

Comments
 (0)