-
Notifications
You must be signed in to change notification settings - Fork 17
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
Jest-like simple interface #7
Conversation
Thanks for this, @truongsinh -- excited to see it merged up! One possible refinement that arises in our test suite: if we're injecting parameters anyway, we may be able to save some configuration by passing in the mocha context directly. describe("Creating snapshot from mocha context", function() {
it("renders correctly", function() {
const tree = renderer.create(<h1>Hello, world</h1>).toJSON()
expect(tree).to.matchSnapshot(this); // <= pass in context
});
}); Later, in // in matchSnapshot
snapshotFileName = snapshotFileName || internalConfig.snapshotFileName;
if (snapshotFileName.test && snapshotFileName.test.ctx instanceof mocha.Context) {
const { title, file } = snapshotFileName.test;
// assign (string) snapshotFileName, snapshotName, etc.
} It wouldn't work with arrow functions, of course (documented/discouraged in mocha docs at any rate), but it may simplify configuration for suites that already rely on mocha's context. |
Thanks for your suggestion @rjz. I would not see configuration as a hassle though, because it's supposed to be only 2 snippets per test file
and
rather than passing One way to reduce configuration further is having something like
Noticed that we no longer need to register file name template. This way, we can still have How does this sound? |
Awesome, @truongsinh! |
@rjz @suchipi @JakeSidSmith new implementation based on previous discussion |
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.
Looks awesome.
Hi @truongsinh, I have given this a first pass look-over. There are some code style issues and some of the documentation/messaging is not clear, but at a glance the pattern itself looks good. I will pull this branch down to my machine tomorrow and make some tweaks and verify everything works in my environment. Just giving you an update. |
Hi @truongsinh, I made some changes and merged. The new interface is available in version 0.3.0.
Thanks for your contribution; even though I made a lot of changes on top of it, it was a great starting point. @rjz @truongsinh @JakeSidSmith please give the new API a try and let me know if it works for you. |
Thanks, @suchipi, @truongsinh, @JakeSidSmith— |
With test and document. #6