How to exclude test files (eg misc.test.js) from the global search results using the `File mask` option?

I'm trying to exclude search results from the test files we have. They are unique in that they do have the ending of `*test.js` vs our regular files of `*.js`.

 

How can I setup the `File mask` feature to exclude them? I've tried

!*test.js

but that didn't work.

 

Thanks in advance,

Andreas

10 comments
Comment actions Permalink

This pattern works fine for me:

0
Comment actions Permalink

Is there a way to do a file mask that will include all *.ts file and at the same time exclude !*.spec.ts file?

0
Comment actions Permalink

Sure, it has to be *.ts,!*.spec.ts

1
Comment actions Permalink

So simple...
Big THX to you Elena. This is exactly what i was searching for!

0
Comment actions Permalink

Hello, is there any way to exclude the .js files in folders named "/__fixtures__/" they are all over the project.

I have try with file mask "*.js,!*__fixtures__/*.js"  or even with more wildcards between fixtures and .is but without success.

0
Comment actions Permalink

No, not currently possible; please follow https://youtrack.jetbrains.com/issue/IDEA-130905 and linked tickets for updates

1
Comment actions Permalink

@Martin Petkov Work

How/where do you search? I mean: is it in specific folders (that can be different every time), predefined scopes or something else etc?

If that's like Project Wide search and you just want to exclude certain folders -- have you tried making your own custom Scope and use it?

1
Comment actions Permalink

Andriy Bazanov in almost every component in our project we have specific folder containing mocked data in files for the tests. The test files can be filtered, since they contain special word in the filenames but these files can't since they are called index.js and the only way to filter them is to be able to filter their folder name.

Unfortunately even if i configure my scope correctly "file[project-app]:*//__folder_to_exclude__//index.js" the files still appear in the search results.

0
Comment actions Permalink

@Martin Petkov Work

Unfortunately even if i configure my scope correctly "file[project-app]:*//__folder_to_exclude__//index.js" the files still appear in the search results.

That should not be happening, otherwise the whole thing would be broken...

It's possible that you have made a mistake somewhere.

1) Please show the Scopes screen that would show that the unwanted files are not included. Perhaps the pattern is not good enough (or cannot be applied for whatever reason)

2) Please show the Find in Files popup where you do your search. Maybe you forgot to select the Scope there? Easy to overlook.

3) The Project View side panel -- please switch to that scope there (instead of the default "Project" one) -- do you see the unwanted files there?

0
Comment actions Permalink

Andriy Bazanov actually you are right, I didn't pick the right scope in the "Find files" modal, it seems to work ok now. Thank you!

I still think that adding support for filtering by the file path in the "Find files" modals (not only by file name) would be much cleaner and easier way to achieve that result.

0

Please sign in to leave a comment.