vendredi 1 mars 2019

JavaScript: Why am I getting this AssertionError?

I have an index.js file that is implementing a forEach helper like so:

var images = [
  { height: 10, width: 30 },
  { height: 20, width: 90 },
  { height: 54, width: 32 }
];
var areas = [];
images.forEach(function(image) {
  return areas.push(image.height * image.width);
});

console.log(areas);

module.exports = images;

I know that solution works, you know that solution works, it works.

Then inside my test.js file:

const chai = require("chai");
const images = require("./index.js");
const expect = chai.expect;

describe("areas", () => {
  it("contains values", () => {
    expect([]).equal([300, 1800, 1728]);
  });
});

When I run npm test, I continue to get an AssertionError.

Aucun commentaire:

Enregistrer un commentaire