         else
           testChain.push boundItem
 
+  # Process uncaught exceptions.
+  _onError: (errorMessage, url, lineNumber, columnNumber, errorObject) ->
+    @_internal.capturedErrors.push {errorMessage, url, lineNumber, columnNumber, errorObject}
+
   @getTestName: ->
     @testName
 

        testCase._processTestFunction testChain, testCase.tearDownServer
        testCase._processTestFunction testChain, testCase.tearDown
        testCase._processTestFunction testChain, ->
          # Ensure that the test failed if it was registered as a failing test.
          if @_internal.options.mustFail
            # Restore exception and event handlers.

    ClassyTestCase.runOnServer @tearDownServer
    ClassyTestCase.runOnBoth @tearDown

    # Test-local internal variables.
    @_internal = {}

    if Meteor.isClient
      # Capture uncaught exceptions.
      originalOnError = window.onerror
      window.onerror = (args...) =>
        @_onError args...
        originalOnError.apply @, args if originalOnError

      @_internal.capturedErrors = []
      @_internal.currentErrors = 0

  @hasTests: ->
    ClassyTestCase._hasTests

