opitzconsulting / uitest.js

uitest.js is able to load a webpage into a frame, instrument that page and the javascript in that page (e.g. add additional scripts at the end of the document, ...) and execute actions on that page.
MIT License
67 stars 8 forks source link

Jasmine-Sugar: uitest.current sometimes delegates to the wrong uitest instance #3

Closed tbosch closed 11 years ago

tbosch commented 11 years ago

For a suite like the following the second call to uitest.current.url will be overridden by the first one:

describe('someSuite', function() {
    it('should set the url', function() {
        uitest.current.url('someUrl1');
    });
    describe('nested suite', function() {
        uitest.current.url('someUrl2');
        it('should be executed with the wrong url set', function() {
            uitest.current.runs(function(location) { 
                expect(location.href.indexOf('someUrl1')!==-1; 
            });
        });
    });
}

The reason for this is in jasmineSugar.js: a path is calculated there that includes the ids of the suites and specs. However, the ids do not contain a marker whether the id belongs to a suite or a spec. So at both calls to .url we have a path of [0,1]. In the first place, the 0 is the id of the suite and the 1 the id of the spec, in the second place both ids belong to suites.

Tobias