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 trialKathryn Notson
25,941 PointsJavaScript Unit Testing > Behavior Driven Development with Mocha and Chai > A Testing Test!
I'm not quite getting the answer to this code challenge. I think the problem is after ".to.have.property({});". Error message: "Version of clone.js DOESN'T work correctly, test expected to fail, but spec passes," or "version of clone.js works correctly, but spec doesn't pass." I've done numerous arrangements of the expectation with either of these error messages. I'm not sure any arrangement passes through clone.js correctly. Everything I've tried is an incorrect answer.
var expect = require('chai').expect
describe('clone', function () {
var clone = require('./clone.js')
it('should return an object where all properties match', function () {
expect(clone).to.deep.equal.all.property;
})
})
function clone (objectForCloning) {
return Object.assign({}, objectForCloning)
}
module.exports = clone
1 Answer
Kathryn Notson
25,941 PointsAre Arnsten:
That's a direct copy from the Chai Assertion Library, but I don't think that's what the instructor was looking for.
Here's the result: "We tried your spec with a version of clone.js that DOESN'T work correctly, expecting test to fail, but it passed.β It's a "Bummer!" statement which means the answer isn't correct & therefore, I can't pass the test question.
Are Arntsen
11,035 PointsIt is almost a direct copy of the Chai Assertion library. You need to put the example object in to the "clone" function. When I do this challenge it passes with the exact syntax as my previous answer. ItΒ΄s strange that it does not work for you no?
Sebastian Karg
28,705 PointsHad trouble with this one as well. Tried the above answer and got a bummer too, but found out that I used "to.equal" instead of "to.eql". After fixing this, the test passed.
Are Arntsen
11,035 PointsAre Arntsen
11,035 PointsHi!
I also struggled with this one. I skipped it and found the answer later in the course. This should work: