Sha256: 486f27ae3d65838923512526322e19d36c7bee1fbea561734a9f6f8f13c64e29

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

UNHANDLED_REJECTIONS = []
# In Firefox promise events are disabled by default.
# We need to enable them in about:config.
window.REJECTION_EVENTS_SUPPORTED = ("onunhandledrejection" in window)

beforeAll ->
  window.addEventListener 'unhandledrejection', (event) ->
    UNHANDLED_REJECTIONS.push(event)

beforeEach ->
  UNHANDLED_REJECTIONS = []

  jasmine.addMatchers
    toHaveUnhandledRejections: (util, customEqualityTesters) ->
      compare: (actual) ->
        # It doesn't really matter what's in actual.
        # A good way to call this is e.g. `expect(window).not.toHaveUnhandledRejections()
        pass: UNHANDLED_REJECTIONS.length > 0

#UnhandledRejectionTracker = do ->
#
#
#
#
#
##beforeEach (done) ->
##  @unhandledRejections = []
##  @trackUnhandledRejections = (event) =>
##    @unhandledRejections.push(event)
##  window.addEventListener('unhandledrejection', @trackUnhandledRejections)
##  done()
##
##afterEach (done) ->
##  hadUnhandledRejections = @unhandledRejections.length > 0
##  @unhandledRejections = []
##  if hadUnhandledRejections
##    done.fail('There were rejected promises without a rejection handler')
##  else
##    done()

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
unpoly-rails-0.57.0 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.7 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.6 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.5 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.4 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.3 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.2 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.1 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.56.0 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.55.1 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.55.0 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee
unpoly-rails-0.54.1 spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee