-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Todo items for watch plugins #5478
Comments
How about |
There is a problem that I've been encountering while implementing Jest plugins to stress the API. In an ideal world, I should be able to do this:Implement the pattern mode by simply using Here is the code for it. const inquirer = require('inquirer');
const ansiEscapes = require('ansi-escapes');
class PatternPlugin {
constructor() {
this._pattern = '';
}
apply(jestHooks) {
jestHooks.shouldRunTestSuite(async testPath => testPath.includes(this._pattern));
}
run() {
console.log(ansiEscapes.clearScreen);
if (this._pattern.length) {
console.log('Active filter:', this._pattern, '\n');
}
return inquirer
.prompt([
{
type: 'input',
name: 'pattern',
message: 'Type pattern:',
},
])
.then(({ pattern }) => {
this._pattern = pattern;
return true;
});
}
getUsageInfo() {
return {
key: 'e'.codePointAt(0),
prompt: 'to enter mega filter mode',
};
}
} And we could get fancier by using more inquirer features and really easily create this: So what is the problem with this?Jest sets run() {
process.stdin.setEncoding('utf8');
console.log(ansiEscapes.clearScreen);
if (this._pattern.length) {
console.log('Active filter:', this._pattern, '\n');
}
return inquirer
.prompt([
{
type: 'input',
name: 'pattern',
message: 'Type pattern:',
},
])
.then(({ pattern }) => {
this._pattern = pattern;
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding('hex');
return true;
});
} I'm not sure what the correct solution would be, but it would be awesome for
cc: @cpojer, @thymikee, @rickhanlonii, @SimenB |
Supporting I also thought when I looked at your gif that it would be cool if that fancy filter also had typeahead. Thoughts on reusing logic between different plugins? Or have them extend one another. |
I think the encoding was just for detecting the keys. utf8 should equally work, no? I really like this idea, btw. |
Got it, thanks!
Yes, we just need to come up with a nice interface for injecting some of the
I think we should start with the first one, given that it seems less opinionated, lower level and simpler to implement. We could probably call it from here https://github.com/facebook/jest/blob/master/packages/jest-cli/src/watch.js#L155-L180, Although I'm not sure if we should pass all the hasteFS files, or just testFiles or what would be a good interface for it. |
Checked off the encoding point 🎉 |
Aaaaand the config one. Just CI env left. Not sure about that one, though |
@rogeliog thoughts on opening up a separate issue for the CI stuff? |
Yes, let's open a separate issue... Although I think we can just close it and then open a separate issue if it is ever needed. |
Yeah, let's do that instead 🙂 |
#5399 was merged, and it rewrites some parts of the watch mode to support third party plugins.
There are still some follow up items that need to be done.
runnerConfig
option to configure runners #4278 (comment) - done in Allow watch plugin to be configured #6603The text was updated successfully, but these errors were encountered: