angular/jasminewd

Error tests for Jasmine 2.X are not working properly when a timeout has occurred before

juliemr opened this issue · 1 comments

The errors for

  it('should pass errors from done callback', function(done) {
    done.fail('an error');
  });

  it('should fail normal synchronous tests', function() {
    expect(true).toBe(false);
  });

are getting merged into one failure.

Note that this only fails if a test times out earlier:

describe('Timeout cases', function() {
  it('should timeout after 200ms', function(done) {
    expect(fakeDriver.getValueA()).toEqual('a');
  }, 200);

  it('should pass errors from done callback', function(done) {
    done.fail('an error');
  });

  it('should fail normal synchronous tests', function() {
    expect(true).toBe(false);
  });
});

This causes the output:

Failures:
1) Timeout cases should timeout after 200ms
  Message:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
  Stack:
    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
        at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

2) things that should fail should fail normal synchronous tests
  Message:
    Failed: Error: an error
  Stack:
    Error: Failed: Error: an error
        at /Users/ralphj/jasminewd/index.js:104:16
        at promise.ControlFlow.runInFrame_ (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
        at promise.Callback_.goog.defineClass.notify (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25)
        at promise.Promise.notify_ (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)
  Message:
    Expected true to be false.
  Stack:
    Error: Failed expectation
        at Env.<anonymous> (/Users/ralphj/jasminewd/spec/errorSpec.js:38:18)
        at /Users/ralphj/jasminewd/index.js:95:14
        at promise.ControlFlow.runInFrame_ (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20)
        at promise.ControlFlow.runEventLoop_ (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/webdriver/promise.js:1755:8)
        at null.<anonymous> (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/webdriver/promise.js:2056:12)
        at goog.async.run.processWorkQueue [as _onTimeout] (/Users/ralphj/jasminewd/node_modules/selenium-webdriver/lib/goog/async/run.js:125:21)
        at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

3 specs, 2 failures
Finished in 5.016 seconds