How do I Run Jasmine Unit Tests Synchronously?

时间:2015-04-24 21:35:59

标签: javascript unit-testing jasmine chutzpah

I am currently using chutzpah to run Jasmine JavaScript unit tests in Visual Studio. I have a globally scoped DOM element that i need to reset each time a couple of my tests run. I am currently using beforeEach() to clear out the DOM element so the next test can use and populate accordingly. However, it looks like i am running into async problems where the element is being cleared in one test while executing in a different test. Bottom line: Is there any way to run each test synchronously in Jasmine? Current structure looks something like this:

describe('baseView', function () {
    beforeEach(function() {
        $('#elementToClear').html('');
    });

    it('run 2.', function () {
        var baseView = new BaseView();
        baseView.populateElement();
        expect($('#elementToClear').html()).toBe('populated')
    });

    it('run 1.', function () {
        var baseView = new BaseView();
        baseView.populateElement();
        expect($('#elementToClear').html()).toBe('populated')
    });
});

0 个答案:

没有答案