small medium large xlarge

Generic-user-small
10 Jan 2017, 16:59
Andy Zhao (13 posts)

Back at it again with some test issues, probably because of user error.

So first, I can’t run jasmine-node on bash; not sure if we’re using jasmine-node or rake jasmine, but rake jasmine works just fine. The book says run jasmine-node so I assume that’s what we’re trying to do.

Second, my beforeEach test keeps failing. Here’s the error code:

) CustomerSearchComponent initial state sets keywords to the empty string
   Message:
     Expected null to be ''.
   Stacktrace:
     Error: Expected null to be ''.
    at .<anonymous> (/Users/WigWog/projects/shine/spec/javascripts/CustomerSearchComponent.spec.js:37:34)

and here’s my test:

var CustomerSearchComponent = require("../../webpack/CustomerSearchComponent");

var component = null;

describe("CustomerSearchComponent", function() {
  describe("initial state", function() {
    it("sets customers to null");
    it("sets keywords to the empty string");
  });

  describe("search", function() {
    describe("A search for 'pa', less than three characters", function() {
      it("sets the keywords to be 'pa'");
      it("does not make an HTTP call");
    });
    describe("A search for 'pat', three or more characters", function() {
      describe("A successful search", function() {
        it("sets the keywords to be 'pat'");
        it("sets the customers to the results of the HTTP call");
      });
      describe("A search that fails on the back-end", function() {
        it("sets the keywords to be 'pat'");
        it("leaves customers as null");
        it("alerts the user with the response message");
      });
    });
  });

  beforeEach(function() {
    component = new CustomerSearchComponent();
  });
  describe("initial state", function() {
    it("sets customers to null", function() {
      expect(component.customers).toBe(null);
    });
    it("sets keywords to the empty string",function() {
      expect(component.keywords).toBe("");
    });
  });
});

Not sure what I’m doing wrong, since it follows the source code too.

Dmfcb_pragsmall
10 Jan 2017, 17:14
David Copeland (433 posts)

Can you post the code you are testing?

The reason jasmine-node isn’t found is likely that it’s installed in node_modules/.bin and the book is (mistakenly) telling you to use that without changing your path. Will fix.

Dmfcb_pragsmall
11 Jan 2017, 12:55
David Copeland (433 posts)

I find just asking for help, even if I don’t get an answer, get lead to me figuring it out. Glad it worked, in this case! :)

You must be logged in to comment