jamesshore / quixote

CSS unit and integration testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReferenceError: before is not defined

devlemire opened this issue · comments

https://github.com/j-lemire/DevMtn-CSS-Store

I cannot get the unit tests to work to save my life, where am I going wrong?

If you pull down my repo, you can run 'npm run karma'

Jasmine uses beforeAll instead of before.

I've updated my syntax and now I have a new error that I cannot assert my element because it is undefined. I also had to remove done because it was undefined as well.

describe("DevMtn-CSS-Store", function() {
var frame, containerHeader;

beforeAll(function() {
	frame = quixote.createFrame({
		src: "/"
	});
});

afterAll(function() {
	frame.remove();
});

beforeEach(function() {
	frame.reload();
	containerHeader = frame.get("#container-header");
});

it('Header container is 100% in width', function() {
	containerHeader.assert({
		width: '100%'
	}, "The header container should have a width of 100%");
});

});

frame.reload takes a callback (see the docs), so you need to wait for the callback to finish before you run the tests:

beforeEach(function(done) {
  frame.reload(function() {
    containerHeader = frame.get("#container-header");
    done();
  });
});

In Mocha, you can have multiple beforeEach functions, which makes this a bit cleaner. I'm not sure if it will work with Jasmine:

beforeEach(function(done) {
  frame.reload(done);
});

beforeEach(function() {
  containerHeaer = frame.get("#container-header");
});

Closing on the assumption that this has been resolved.