Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,274 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,274 Points

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