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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make RuleTester test runner agnostic #6227
Comments
RuleTester used to have a hard dependency on Mocha, but it was removed to satisfy some plugin requirement of using Jasmine instead. It works by the fact that both Mocha and Jasmine use the same syntax ( I think what you are currently doing is not too bad. It's a bit hacky, but then what you are trying to do is a bit hacking in on itself:-) We could add a second parameter to RuleTester constructor, but it wouldn't really be all that much different than what you are already doing, and it would also be harder to setup defaults for it (I think). P.S. In general I'm pretty interested in this, due to the fact that our unit tests are taking a while to run (since we have so many of them). If we could have an option of painlessly switching to AVA at some point, and running them in parallel, it might significantly improve our build time. |
QUnit has
Yeah, probably not. And I would probably still need to install a package that does the bridge between RuleTester and AVA, so that I wouldn't have to write this in every test file. But at least I would have some greater garantees that this wouldn't break in some ESLint internal refactor. Right now I'm just hoping that you don't move this part too much, but with some sort of hook, I'd feel safer because I know I could at least rely on semver.
Yeah, saw your comment in the roadmap issue :) If you're curious and want to have a look, I know at least 3 projects using RuleTester and AVA: eslint-plugin-ava, eslint-plugin-lodash-fp, eslint-plugin-xo. |
I would be fine with adding another optional parameter to the RuleTester constructor that could supply overrides for |
RuleTester appears to only depend on
馃憤 - Assuming I am right about |
Yeah, understandable, especially since I do have a work around for this. If this gets accepted, I may try to submit a PR, depending on how complicated this will be. |
Sorry, trying to get caught up here. First, You can already override I did just skim this over briefly, so do let me know if I'm missing something important. |
@nzakas The main thing would be semver garantee. Then as @jamestalmage mentionned, if we could inject an @ilyavolodin I just checked what @jamestalmage said, and I don't see any use of |
Ah, you are correct. |
Implementing this would greatly improve, this situation . At a minimum, let's add a few tests validating what happens when you replace |
@jfmengels RuleTester is part of our exported API, so it follows semver when it comes to changes. Allowing @jamestalmage we happily accept pull requests with more tests. |
@jfmengels can you refine your proposal based on this discussion? |
My initial proposal is basically solved if you tell me that you consider the On the proposed Thanks for answering! (and sorry for not responding earlier btw) |
Yeah, @jamestalmage if you want to propose something around assert, please open a new issue. |
@jfmengels Could you = we who submits a pull request to document |
@pedrottimark I can give it a shot. Would this be a good spot to put it http://eslint.org/docs/developer-guide/working-with-plugins#testing? There's no other section dealing with it afaik. |
@jfmengels yeah, that's a good spot. Probably just a section for customizing RuleTester there would do. |
Hey guys!
I have a few ESLint plugin repos I'm maintaining, where we use
AVA
as the test runner instead ofmocha
(includingeslint-plugin-ava
馃槃). What we did until now was to wrap the whole RuleTester call in one AVA test, which made the test feedback pretty bad (it's all good or all fail, you don't know which one crashed, and the error messages were simplistic), just like if you would simply run the test file usingnode
instead ofmocha
.I noticed that by overriding the RuleTester's
before
andit
methods, I could create proper test suite 脿 lamocha
, and created https://github.com/jfmengels/eslint-ava-rule-tester. It feels a bit hacky and fragile, so I would have liked to know if there was a better way, or if we could introduce one, to make RuleTester more test runner agnostic.I provided screenshots of actual behavior with
AVA
and the behavior witheslint-ava-rule-tester
in this PR (source code available there if needed) avajs/eslint-plugin-ava#105.I'm not sure about the solution to offer, but it would probably be something like adding a new parameter to
RuleTester
, which could be either an object with keysdescribe
andit
(which would be functions that create tests), or a new function that returns that.(cc @sindresorhus @twada @jamestalmage)
Oh, and by the way: Love the work that you guys are doing, thanks so much for the work you're putting into this 鉂わ笍, I don't express it often enough.
The text was updated successfully, but these errors were encountered: