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!

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 A Testing Test!

What 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

disregard let newU = clone(users); didn't use it.

1 Answer

Jesus Mendoza
Jesus Mendoza
23,288 Points

Hey Antony,

Did you try with


Thanks 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
Jesus Mendoza
23,288 Points

I was going to suggest you that but when I read the documentation it seemed the same to me