-
Notifications
You must be signed in to change notification settings - Fork 16
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
Migrate sinon-test from sinon package. #1
Conversation
Extract `sinon.test` and `sinon.testCase` from the current sinon 2.0-pre package. Modify both methods to be indenpendant of `sinon.config`.
Looking good! I have some thoughts: The dependency on Sinon is unfortunate, as it will require constant republishing of this package. I understand the appeal of I suggest the following API instead: sinon.test = require('sinon-test')(sinon);
sinon.test = require('sinon-test')(sinon, config); or, more explicit: sinon.test = require('sinon-test').configure(sinon);
sinon.test = require('sinon-test').configure(sinon, config); But then, how to access sinon.testCase = require('sinon-test').configureTestCase(sinon, config); Other suggestions? Now that we're using browserify, do we need all the closures and scaffolding in the modules? Couldn't we just make them regular CommonJS modules? |
Agree with removing the explicit |
How can you throw an error on require? I don't see the difference: sinon.test = require('sinon-test');
sinon.test(); // This can throw a predefined error regardless of the chosen API |
I was struck by temporary retardedness 😭 You are absolutely right. |
I think the ideal solution requires |
I'm not sure I agree. Those modules would still come with the version conundrum. I think injection is the ideal solution, as it would allow |
Well, I was thinking of using the default npm versioning and depend on One example might help to illustrate my point: On the other hand, with the injection, a major upgrade of either module most likely requires the other one to be upgraded too. |
I still think the problem that if using With injection, sure there might be problems when |
Sorry @cjohansen, but I think you misunderstand my suggestion. If we use carets in the version numbers, e.g. |
Gents, I have updated the API so it no longer has an NPM dependency on sinon; however the Any input would be greatly appreciated; I would love to just bundle up the tests themselves using browserify (and thereby not have to reference the window object in any of the tests); but I have no idea how to get buster and browserify to play nice :( Are there any buster experts in the room (paging @mroderick ) |
Anyone? Can't help but think things would be much simpler to test if were using a less opinionated test-runner (like mocha) instead - would there be any objections to me migrating these tests over? Then I can just browserify all the tests and run them through phantom. |
@cjohansen is the buster expert ;-) I am returning from vacation and still have tourist mode engaged. Once I am back to daily life, I can look into the discussion of test runners Anyway, I think we should discuss test runners in it's own thread |
Use browserify-shim to replace require calls with references to `window.buster`; this allows us to remove all the IIFE shims from the test-cases and use `require` in the packaged tests.
Thanks for the reply @mroderick. So after my rant above I set out to figure out how to fix this; and hopefully I now have a working solution. The browserify-shim package allows us to replace |
Had to drop one test as it was tightly coupled to the old `sinon.test` global.
Hey all, so the tests are passing on travis, but the Node 0.8 build is hanging / failing on buster; I copied the config straight from the sinon repo; anyone have any idea what's causing this? Any objections to turning off the 0.8 build? |
Hmm ... I restarted the 0.8 build, and it still failed. I do not really see why we should keep on to the 0.8 version of Node as it is almost 4 years old. |
My opinion on two issues raised:
|
+1 for removing old node support. It goes without saying, if we're switching to Mochify I'm keen to support whatever is needed in the Sinon context. |
OK, dropped Node 0.8 builds from Travis and everything is green. This PR is ready for review, please take a look. |
LGTM 👍 |
@@ -0,0 +1,17 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to keep all this boilerplate in all files? If we're providing a built version using Browserify, can't we just add a banner during the build step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was under the impression this was the copy's standard copyright / description block. I have no issue with leaving it in, or taking it out - just say the word :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether it's good enough to prepend this in the browserified version. This is also shipped and executed as-is in node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea why it's there in the first place. We do have a LICENSE, so repeating it in every file seems superfluous. It should be enough with a short description of the module. The rest is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point.
Other than the comment about the boilerplate, I have no comments. Excellent work @jonnyreeves |
Gents, anything stopping this one from landing? Once it's merged we can merge sinonjs/sinon#973 and I can get the ball rolling on migrating all the sinon tests over to using CommonJS. |
Migrate sinon-test from sinon package.
👍 Sorry for the delay. |
Extract
sinon.test
andsinon.testCase
from the current sinon 2.0-pre package. Modify both methods to be independent ofsinon.config
.Still need to get the test-case tests back on their feet (they stubbed on
sinon.test
so are a little tricky to migrate) - but otherwise it's taking shape.Please let me know your thoughts about the proposed API.