jasmine.async icon indicating copy to clipboard operation
jasmine.async copied to clipboard

Preserve execution context

Open mgrandrath opened this issue 12 years ago • 0 comments

This change preserves the execution context in functions passed to async.beforeEach etc. so that the following code works:

describe("something", function () {
  var async = new Async(this);

  async.beforeEach(function (done) {
    var self = this;
    doSomethingAsync(function (asyncResult) {
      self.result = asyncResult;
      done();
    });
  });

  it("is ready", function () {
    expect(this.result).toBeDefined();
  });
});

mgrandrath avatar Nov 13 '13 12:11 mgrandrath