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
WIP: feat: add platform-conditional ignore hints #619
base: main
Are you sure you want to change the base?
WIP: feat: add platform-conditional ignore hints #619
Conversation
This adds the ability to create ignore hints that are only effective on specific platforms, so that we can ignore some test branches that are only relevant to specific platforms by using a hint like: /* istanbul ignore next platform!=win32 */ /* istanbul ignore else platform=linux */ and so on. No tests yet.
I don't know if this is something that would be acceptable, or if it should be somehow abstracted to look at |
Maybe instead of hardcoding “platform”, conditional ignores could be generic - ie, you put whatever condition name you want in the comment, and the config/command-line invocation would determine whether that condition name is undefined, true, or false, and it’d be a noop when undefined? |
To avoid a breaking change, maybe the syntax could be: /* istanbul ignore-conditional (file|if|else|next) (condition(s)...) comment */ So the first item that isn't a conditional means the rest is just comment, and users can always use Ignore hint will be valid if ALL conditions are met. (To OR the conditions, use multiple hints.) Conditions:
Some thoughts on extending this to more generic/unbounded set of keys and values might look like this. Keys and values may be double-quoted, so Keys available:
I'm not sure how to go about doing ignores for browsers. Would that entail some kind of run-time handling? Or is instanbul itself sometimes run within a browser context? The downside of having open-ended values (instead of process.platform or process.arch, which have a small number of possible values) is that the parsing gets more involved, since environment variables and arguments may contain spaces, quotes, and escape characters. |
env values can be provided pretty easily by bundlers to browsers, so that might be sufficient? |
Just started looking at this repo a little bit again 👍 will make an effort to give this review. |
@bcoe awesome! Feel free to ping me on the various slacks if you have any feedback on it. |
This adds the ability to create ignore hints that are only effective
on specific platforms, so that we can ignore some test branches that
are only relevant to specific platforms by using a hint like:
and so on.
No tests yet.