Skip to content
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

Use a proper test runner and actually assert expected behavior #18

Merged
merged 2 commits into from
Mar 11, 2020

Conversation

lo1tuma
Copy link
Contributor

@lo1tuma lo1tuma commented Feb 14, 2020

The current test setup only printed some log messages, without checking the result. So even if a breaking change is introduced the tests wouldn’t fail. That’s why I think it is a good idea to use a proper test runner and do proper assertions.

@lo1tuma
Copy link
Contributor Author

lo1tuma commented Mar 11, 2020

Any feedback on this PR?

@gillchristian gillchristian self-requested a review March 11, 2020 13:29
Copy link
Owner

@gillchristian gillchristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lo1tuma this is awesome!

I'm working on #17 and I was going to add a test runner myself since I needed to do proper testing there.

Code looks good. I have only one question.

Also, for a future PR we could add a more extended set of test cases to cover different types of reported errors. But that would be for a follow up PR. If you want to do it feel free, otherwise I'll do it.

const result = PrimitiveType.decode('');

t.deepEqual(reporter(result), []);
t.end();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q]: I'm not familiar with tape. Is t.end required for synchronous tests? Otherwise we could remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends. If you are using t.plan() to plan the amount of assertions then t.end() is not required.
See the documentation here.

I’m also open for other test runners, personally I use ava quite often. But since this project is quite small and doesn’t need things like async testing I thought a lightweight and fast test runner might be enough.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been working with Jest for 4 years already. So that's all that I know. But I'm fine with new stuff, specially if it's lightweight. We can change it later, it's not a big project.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already past, but @gillchristian fyi ava is near the same as tape in the style of its API, doesn't require the t.end() call, and has cleaner output - so if you'd prefer that I could drop that in in like 3 minutes. although this doesn't and won't do anything async at least you dont need to do that :)

though I recommend against jest since it's huge and includes a bunch of stuff that this project doesn't need like automocking and whatever, as well as relying on globals and babel transforms and stuff which makes configuration end up way more complex. tape and ava are both super simple and do anything this library will probably ever need.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with AVA as well. Used it when it just came out and I liked it.

@lo1tuma wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AVA is my favourite test runner anyway, so I’m 👍 for this change.

@lo1tuma
Copy link
Contributor Author

lo1tuma commented Mar 11, 2020

Also, for a future PR we could add a more extended set of test cases to cover different types of reported errors.

I agree. Actually I did this PR because I was planning to make a follow-up PR to solve an issue when using intersections, but I want to make sure I don’t break the existing functionality.

@gillchristian gillchristian merged commit 8d259e9 into gillchristian:master Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants