File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,10 +70,11 @@ module.exports = {
7070
7171function isInTestDirectory ( filename ) {
7272 const filenameParts = path . normalize ( filename ) . split ( path . sep ) ;
73- // Must contain a tests/ or test/ segment, and must not be under app/ or addon/
74- const hasTestDir = filenameParts . includes ( 'tests' ) || filenameParts . includes ( 'test' ) ;
75- const isAppCode = filenameParts . includes ( 'app' ) || filenameParts . includes ( 'addon' ) ;
76- return hasTestDir && ! isAppCode ;
73+ const testDirIndex = filenameParts . findIndex ( ( part ) => part === 'tests' || part === 'test' ) ;
74+ // tests/ or test/ must be a top-level directory (index 0) or directly under
75+ // a project name (index 1, e.g. my-app/tests/). Deeper nesting like
76+ // app/components/tests/ is not a real test directory.
77+ return testDirIndex >= 0 && testDirIndex <= 1 ;
7778}
7879
7980function isTestHelperFilename ( filename ) {
You can’t perform that action at this time.
0 commit comments