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')
});
});