0

I am not sure why I am failing tests here, can anyone shed some light? I am also not seeing the correct file show up in DevTools sources, so I am thinking that might have something to do with it, but I am not entirely sure.

cleanObject.test.js

const cleanObject = object => {
  for (let prop in object) {
    if (
      object[prop] === null ||
      object[prop] === undefined ||
      object[prop] === ""
    ) {
      delete obj[prop];
    }
  }
};

describe("cleanObject", () => {
  it("removes null, undefined, and empty string values", () => {
    const dirty = {
      a: "",
      b: undefined,
      c: null,
      d: "value",
      e: false
    };

    const clean = cleanObject(dirty);

    expect(clean).to.deep.equal({
      d: "value",
      e: false
    });
  });
});

cleanObject.test.js in DevTools Sources

/**
 * Take an object and remove null, empty, or undefined values.
 * 
 * @param {Object} object
 * @returns {Object}
 */
const cleanObject = (object) => {
  // complete the function
};

describe('cleanObject', () => {
  it('removes null, undefined, and empty string values', () => {
    const dirty = {
      a: '',
      b: undefined,
      c: null,
      d: 'value',
      e: false,
    };

    const clean = cleanObject(dirty);

    expect(clean).to.deep.equal({
      d: 'value',
      e: false,
    });
  });
});

It seems the file is not being sent over to the browser. Can anyone see where I may be going wrong here?

Chris
  • 33
  • 5
  • 3
    Is it possible that you've got an old/cached version of the file? A good way to verify is to right-click the refresh button with the dev-tools open and select "Empty Cache and Hard Reload" – Joseph Reeve Apr 18 '18 at 17:39
  • that fixed it, thanks! – Chris Apr 18 '18 at 17:41

1 Answers1

1

The js file was cached (read: HTTP Caching). There are various ways to stop this from happening with server configurations, client-side cache busting, or just plain-old cache clearing.

When developing, often the best way to avoid this kind of issue is to "Empty Cache and Hard Reload" by right-clicking the refresh button with the dev-tools open: Read More

Joseph Reeve
  • 400
  • 2
  • 13