-
Notifications
You must be signed in to change notification settings - Fork 14
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
Plugin support #27
Comments
Opened #28 for |
Currently We could make Alternatively, we could make a separate function to register cleanup functions like As a developer using the library, is confusing to register |
The nicest pattern I found is this mixin pattern. It's designed for ES6 classes, and it's decorator-friendly. There's even a library that makes it really easy to follow. If IcedFrisby is going to be maintained going forward, migrating to ES6 classes is a good idea. They're supported natively in Node 6. I doubt we really need to worry about targeting browsers. If users are on an old version of Node, they can use an older version of the library. In the short term, I'd suggest sticking with ES5-style prototypal inheritance, while following this pattern as closely as possible. That way, it'll be an easy transition to classes. I made a proof of concept of an "icedfrisby-nock" plugin. It relies on a hack to get access to the Frisby constructor, and would be much cleaner if the module exported that constructor instead. I'll open a PR for that. Cleanup is unreliable, as I mentioned in my comment above. For setup, it depends on #28. |
Opened #29 to export the constructor. |
@MarkHerhold Are you available to weigh in on significant design decisions? In particular I'd love your thoughts on when |
I would tend to disagree with the notion of making Here's my reasoning. Most of it boils down to user experience.
Given this, I think As for the Node.js support and new features, I usually deprecate and remove support for older versions of Node.js as soon as possible because supporting older versions of everything slows the overall community down. Also, no one likes writing code for old platforms. |
Thanks, that's super helpful. I hadn't considered chaining multiple requests together. I agree with your conclusion. It makes sense for I agree with your points about backward compatibility as well. In the long run, I'd like to make the API as clear as possible and avoid the semantic clash with Mocha. Perhaps at some point we could identify a synonym, make that an alias, and eventually deprecate the original. Maybe Re Node, makes sense about pushing things forward! |
Added tests of the current |
…#32) - Break toss() into methods to allow stubbing - Improve readability by making the methods shorter. - Avoid using `it` as an identifier, since it is a Mocha global. - Remove parameter to `toss()`, which is redundant with `retry()`, and was broken - Remove useless assignment to `retry` variable - Add tests for the behaviors of `after()` callbacks discussed in #27
Added |
Opened #46 to migrate to an ES6 class. At that point all that's left to do here is write a bit of documentation. My plugin is working well: https://github.com/paulmelnikow/icedfrisby-nock |
- Document plugin support (Closes #27) and link to icedfrisby-nock - List maintainers and update contributing info - Fix indentation and remove semis in code
As I mentioned in #26 I'm working on a POC of some tests for https://shields.io/ (see badges/shields#927).
I'd like to add plugins for:
nock
.intercept(nock => nock(...).get(...))
I noticed custom plugins were mentioned in the readme. Any thoughts on how the inheritance would be implemented, or libraries with good patterns to follow? Mixins could be a way to do it.
The nock plugin would also need a
before()
function to register callbacks, as a counterpart toafter()
, which seems straightforward enough.The text was updated successfully, but these errors were encountered: