Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Unit Testing Behavior Driven Development with Mocha & Chai Answer: Expanding Our Expectations

Johnny Austen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Johnny Austen
Front End Web Development Techdegree Graduate 35,494 Points

Finding it very difficult to engage with this course...

Has anyone else struggled with this section of the course? Might be the long videos or perhaps just my application, but I don't feel I'm really picking this up. At the same time, it doesn't really seem crazy complicated either. Has anyone else struggled with this section?

2 Answers

I am struggling too currently.

In fairness, while I understand the concept of testing and the language of the methods seem straight forward (e.g. expect() and to.be.true) this is my first ever practice. Rather than being able to focus on just the syntax, it's a different approach to developing and I'm trying to understand the logic of building a battleship game too! For me, at this stage, it feels like too many unknowns.

I knew how to write up the 'describe' section and link it to the fire function in ship_methods.js but it was the logic of the task that I didn't know what I needed to do. Here were my thoughts:

  • it('should show both functions fired') - first guess
  • it('should show checkforShip fired') then damageShip - as should be independent

Then wondered how this worked at all as the words 'unit' and 'independent' stuck in my mind from the lessons. You don't want overlap for a 'unit test' but this is an overlap?!

As Guil begins the answer it feels that you give an example and see it run all the way through. Currently, in my mind, that sounds like 'integration testing' that was said to be explicitly different.

I will chalk this up as a good first run through that I can refer back to later. Personally, I have used a few projects now that used npm scripts and was pleased to be more comfortable with that.

Yes, almost finished watching the answer video but because I don't fully grasp what the logic is doing, I have a very thin understanding of what the expectations are that are being set.

Timo Koskinen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Timo Koskinen
Full Stack JavaScript Techdegree Graduate 24,972 Points

I found this all very difficult at first. But then I took a pause for 2 hours during this clip and just wrote my own functions and tested all kind of super easy things. I just wanted it all to be simple and see what is in the provided Chai BDD API Documentation. Very time consuming for sure. Then I went back to this task and it all clicked in my head.