diff options
| author | Elliott Sprehn | 2010-10-19 13:17:49 -0700 | 
|---|---|---|
| committer | Elliott Sprehn | 2010-10-20 14:38:00 -0700 | 
| commit | 2115db69035c5993533fe7a3825e64cf6e9068ad (patch) | |
| tree | 796a502b28cd2bda8108a672eac0bf28c8bc21d4 /test/scenario/SpecRunnerSpec.js | |
| parent | 9c8b1800b90e14b643bab6ada8e96f8f850e84a6 (diff) | |
| download | angular.js-2115db69035c5993533fe7a3825e64cf6e9068ad.tar.bz2 | |
Lots of stability and performance updates and UI polish too.
Polish the Scenario Runner UI to include:
- a scroll pane that steps appear in since the list can be very long
- Collapse successful tests
- Show the line where the DSL statements were when there's an error (Chrome, Firefox)
Also:
- Remove lots angular.bind calls to reduce the amount of stack space used.
- Use setTimeout(...,0) to schedule the next future to let the browser breathe and have it repaint the steps. Also prevents overflowing the stack when an it() creates many futures.
- Run afterEach() handlers even if the it() block fails.
- Make navigateTo() take a function as the second argument so you can compute a URL in the future.
- Add wait() DSL statement to allow interactive debugging of tests.
- Allow custom jQuery selectors with element(...).query(fn) DSL statement.
Known Issues:
- All afterEach() handlers run even if a beforeEach() handler fails. Only after handlers for the same level as the failure and above should run.
Diffstat (limited to 'test/scenario/SpecRunnerSpec.js')
| -rw-r--r-- | test/scenario/SpecRunnerSpec.js | 73 | 
1 files changed, 58 insertions, 15 deletions
diff --git a/test/scenario/SpecRunnerSpec.js b/test/scenario/SpecRunnerSpec.js index e62bb392..dd7a1b72 100644 --- a/test/scenario/SpecRunnerSpec.js +++ b/test/scenario/SpecRunnerSpec.js @@ -49,11 +49,24 @@ ApplicationMock.prototype = {  describe('angular.scenario.SpecRunner', function() {    var $window;    var runner; +   +  function createSpec(name, body) { +    return { +      name: name, +      before: angular.noop, +      body: body || angular.noop, +      after: angular.noop +    }; +  }    beforeEach(function() {      $window = {}; +    $window.setTimeout = function(fn, timeout) { +      fn(); +    };      runner = angular.scope();      runner.application = new ApplicationMock($window); +    runner.$window = $window;      runner.$become(angular.scenario.SpecRunner);    }); @@ -78,11 +91,11 @@ describe('angular.scenario.SpecRunner', function() {    });    it('should execute spec function and notify UI', function() { -    var finished = false; +    var finished;      var ui = new UIMock(); -    var spec = {name: 'test spec', fn: function() { -      this.test = 'some value'; -    }}; +    var spec = createSpec('test spec', function() {  +      this.test = 'some value';  +    });      runner.addFuture('test future', function(done) {        done();      }); @@ -100,11 +113,11 @@ describe('angular.scenario.SpecRunner', function() {    });    it('should execute notify UI on spec setup error', function() { -    var finished = false; +    var finished;      var ui = new UIMock(); -    var spec = {name: 'test spec', fn: function() { +    var spec = createSpec('test spec', function() {         throw 'message'; -    }}; +    });      runner.run(ui, spec, function() {        finished = true;      }); @@ -116,9 +129,9 @@ describe('angular.scenario.SpecRunner', function() {    });    it('should execute notify UI on step failure', function() { -    var finished = false; +    var finished;      var ui = new UIMock(); -    var spec = {name: 'test spec', fn: angular.noop}; +    var spec = createSpec('test spec');      runner.addFuture('test future', function(done) {        done('failure message');      }); @@ -130,16 +143,17 @@ describe('angular.scenario.SpecRunner', function() {        'addSpec:test spec',        'addStep:test future',        'step finish:failure message', -      'spec finish:failure message' +      'spec finish:'      ]);    });    it('should execute notify UI on step error', function() { -    var finished = false; +    var finished;      var ui = new UIMock(); -    var spec = {name: 'test spec', fn: angular.noop}; -    runner.addFuture('test future', function(done) { -      throw 'error message'; +    var spec = createSpec('test spec', function() { +      this.addFuture('test future', function(done) { +        throw 'error message'; +      });      });      runner.run(ui, spec, function() {        finished = true; @@ -149,7 +163,36 @@ describe('angular.scenario.SpecRunner', function() {        'addSpec:test spec',        'addStep:test future',        'step error:error message', -      'spec finish:error message' +      'spec finish:' +    ]); +  }); +   +  it('should run after handlers even if error in body of spec', function() { +    var finished, after; +    var ui = new UIMock(); +    var spec = createSpec('test spec', function() { +      this.addFuture('body', function(done) { +        throw 'error message'; +      }); +    }); +    spec.after = function() { +      this.addFuture('after', function(done) { +        after = true; +        done(); +      }); +    }; +    runner.run(ui, spec, function() { +      finished = true; +    }); +    expect(finished).toBeTruthy(); +    expect(after).toBeTruthy(); +    expect(ui.log).toEqual([ +      'addSpec:test spec', +      'addStep:body', +      'step error:error message', +      'addStep:after', +      'step finish:', +      'spec finish:'      ]);    });  | 
