Skip to content

Commit

Permalink
Better test file regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 4, 2020
1 parent 8639f96 commit c7c24c5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/next/telemetry/events/build.ts
Expand Up @@ -25,8 +25,7 @@ type EventBuildOptimized = {

const REGEXP_DIRECTORY_DUNDER = /[\\/]__[^\\/]+(?<![\\/]__(?:tests|mocks))__[\\/]/i
const REGEXP_DIRECTORY_TESTS = /[\\/]__(tests|mocks)__[\\/]/i

const TEST_FILE = /\.(spec|test)\.[jt]sx?$/i
const REGEXP_FILE_TEST = /\.(?:spec|test)\.[^.]+$/i

export function eventBuildOptimize(
pagePaths: string[],
Expand All @@ -44,7 +43,7 @@ export function eventBuildOptimize(
REGEXP_DIRECTORY_DUNDER.test(path)
),
hasTestPages: pagePaths.some(
path => REGEXP_DIRECTORY_TESTS.test(path) || TEST_FILE.test(path)
path => REGEXP_DIRECTORY_TESTS.test(path) || REGEXP_FILE_TEST.test(path)
),
},
}
Expand Down

0 comments on commit c7c24c5

Please sign in to comment.