DEV Community

Kevin Kaland
Kevin Kaland

Posted on • Updated on

WIP: Testing in Meteor

While reading through the Meteor Guide article on testing, I noticed that the section on acceptance testing still recommended Chimp. Chimp is...a bit old at this point, and Chimp 2.0 is not maintained. I see people on the forums recommending cypress.io for acceptance tests.

Since I do I have one end-to-end test I want to write, I figured I'd try to document at least some of my experience setting up testing in my app DayMeter as I go. I might also propose changes to the Meteor Guide article. This post will be my way of thinking about it.

I'll be starting implementation this week (it's 27 Apr 2021 right now), so I will come back and revise this post as I go.

28 Apr:

I'm seeing varying opinions on what to use for unit and integration tests. jkuester and @hexsprite generally use what's in the Guide.

awatson1978's approach differs in some ways. She uses Jest for UI testing and Nightwatch for end-to-end tests. Cypress isn't mentioned, but it might not have been as mature in 2019. I don't know enough to comment.

I'm going to start with the Meteor Guide recommendations and see if they get the job done. I'll probably try to use as few packages as possible unless things start getting cumbersome. I don't have many initial tests to write, so I'll see how things go.

29 Apr:

A lot of people seem to just use Cypress. I probably could too, although I have one method where I probably want to make sure it's working a little more closely than just looking at its output. So I'm going to try Mocha and an integration test for that.

22 Sep:

Long break, right? 😅 I've been working on this again, and have settled on using Mocha for integration tests. It works great for my purposes. I'm also using xolvio:cleaner to reset the database before each test. I was able to fix a longstanding bug in the app and ensure I didn't cause any critical regressions. I'm glad I wrote tests!

Today, I have to figure out what I want to do for acceptance testing. Once that's done, I'll take a look at Storybook testing again if I have time. There's a different testing landscape there, some of it brittle, some of it more stable. I have to think about if I have any "critical paths" that I'm likely to break as I keep developing things or if simply have stories for each component that I check up on manually is good enough (given that I will also have acceptance for the most important functionality).

I'm leaning towards not doing more testing in Storybook specifically yet. That seems like the right amount of testing for now.

I'll then aim for test-driven development (TDD) going forward.

Top comments (1)

Collapse
 
wizonesolutions profile image
Kevin Kaland

I'm trying to edit this again, but it's cutting off part of the post, so I'll post a comment. Idriss Mahjoubi wrote a fantastic guide to end-to-end testing with Cypress. So that's what I'll go with when I get to it. For now, I need to change some things in my app that I don't have time for right now, so I'm going to finish off this post here and do it later. Hit me up on Meteor Slack with any questions.