jest-community / jest-watch-typeahead

Jest watch plugin for filtering test by file name or test name
MIT License
408 stars 16 forks source link

Fuzzy Search #19

Open reyronald opened 6 years ago

reyronald commented 6 years ago

So I've been waiting for the type-ahead to come back ever since it was removed a few versions ago so that I could propose a Fuzzy Search filtering in addition of (or replacement?) the already existing ones. I searched through the jest and this repo's issues and I've seen a few mentions of it but no formal discussion.

Implementing it is sort-of straightforward since all the heavy lifting is already in place so I thought to give it a shot to have something to show on this issue, what I have in mind could look something like this:

jest fuzzy typeahead

Most developers are already familiar with the UX surrounding fuzzy searching and personally I would find it more useful than the regex ones in most cases, if not all.

So what does the team think? Is this something that could be included in this repo's roadmap? I volunteer to work on this if it is.

/cc @cpojer

rogeliog commented 6 years ago

Yes! This is definitely on the roadmap. I was working on a PR for generalizing some of it to support globs, but the idea is that we should be able to support different search strategies. More info here https://github.com/jest-community/jest-watch-typeahead/issues/15

Since Jest 23.3 plugins can be configured, so I was thinking that it would result in a config like this.

"watchPlugins": [
  [jest-plugin-filename, { "filter": "fuzzy" }]
],
reyronald commented 6 years ago

Cool! I definitely see glob filtering being very useful as well! Hadn't occurred to me.

What's cool about fuzzy is that it can be re-used maybe identically for the testname / testsuite plug-in too.

If you get the configuration system alone merged before advancing a lot of work into some of the specific search strategies perhaps we could work together in the glob and fuzzy ones in parallel and get them to ship quicker and in the same release. Let me know if you are interested.

And by the way, great work on the typeahead feature! It's one of my favorite things about Jest! 😍

unional commented 6 years ago

"watchPlugins": [ [jest-plugin-filename, { "filter": "fuzzy" }] ],

That would limit the filter to "fuzzy", maybe making it an object?

"watchPlugins": [
  ["jest-watch-typeahead", { 
    "filename": true | {  ...filename matching config... },
    "testname": true | { ...testname matching config... },
    "fuzzy": true | { ...fuzzy config... }
  }]
]
larrybotha commented 4 years ago

Any progress or interest in this? This would save a massive amount of time finding tests in deeply nested paths.

SimenB commented 4 years ago

PR welcome 🙂

Andarist commented 3 years ago

@SimenB do you think the fuzzy algorithm should become the default? My personal take on this would be that - yes, it would be great as a default. Not sure how do you feel about it though.

I've looked at how VSCode handles this and it seems that they have a custom implementation:

I'm not really up to implementing still like this - I would much more prefer to just outsource this quickly to a handy npm package 😅 I've found this fuzzysearch and its implementation os very similar (but not the same) as the one in VSCode's fuzzyContains. Thoughts?

cpojer commented 3 years ago

Yes, fuzzy search should be the default! Send a PR :)