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 trialAnthony Blanton
20,056 PointsWhat is the correct way to frame this test spec?
So I get this to work in my editor but I keep getting the error saying it passes with a broken clone.js function that should fail. What am I doing wrong?
var expect = require('chai').expect
describe('clone', function () {
var clone = require('./clone.js')
it('should clone object', function () {
let users = {id:93}
let newU = clone(users);
expect(clone(users)).to.eql({ id: 93 });
});
});
function clone (objectForCloning) {
return Object.assign({}, objectForCloning)
}
module.exports = clone
1 Answer
Jesus Mendoza
23,289 PointsHey Antony,
Did you try with
expect(newU).to.eql(users);
Anthony Blanton
20,056 PointsThanks Jesus,
However it does not work. I don't know why, but i had to use expect(clone(users)).to.deep.equal(users);
. I was under the impression it was just a more verbose way of doing the same thing, but I guess not. Funny thing is I tried that first but was using "to.deep.equals" and moved on to other methods. SMH
Jesus Mendoza
23,289 PointsI was going to suggest you that but when I read the documentation it seemed the same to me
Anthony Blanton
20,056 PointsAnthony Blanton
20,056 Pointsdisregard
let newU = clone(users);
didn't use it.