jamesshore / quixote

CSS unit and integration testing
Other
848 stars 45 forks source link

ReferenceError: before is not defined #35

Closed devlemire closed 7 years ago

devlemire commented 7 years ago

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'

jamesshore commented 7 years ago

Jasmine uses beforeAll instead of before.

devlemire commented 7 years ago

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%");
});

});

jamesshore commented 7 years ago

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");
});
jamesshore commented 7 years ago

Closing on the assumption that this has been resolved.