Profile picture
A web developer's blog
December 04, 2021
Visual Studio Code — finding all files that *do not* contain a certain string

I was running a Karma test suite containing a few hundred unit tests, when I got into this error:

Can’t bind to ‘some-property’ since it isn’t a 
known property of ‘some-component’

Now, I happen to know that this is caused by a missing [NO_ERRORS_SCHEMA] in one or more of the spec files.

But — the Karma tests runner does not provide any info about the actual names of the files having this issue.

So — how to solve this problem then: “get a list of all *.spec.ts files in my project that do not contain the ‘NO_ERRORS_SCHEMA’ string”?

Luckily, there’s a Visual Studio Code extension for that: ReverseSearch. Once installed, do this:

  1. Press Ctrl + P, open Reverse Search:

1

  1. Enter a string. We'll use "NO_ERRORS_SCHEMA" here:

2

  1. Choose files to include. We'll use "**/*.component.spec.ts" here:

3

  1. Choose files to exclude. We'll use "!**/*.component.spec.ts" here:

4

  1. Done! Matching files will be presented in the Output panel:

5

Cool, right?