File tree Expand file tree Collapse file tree 3 files changed +27
-45
lines changed
addon-test-support/@ember/test-helpers Expand file tree Collapse file tree 3 files changed +27
-45
lines changed Original file line number Diff line number Diff line change 22import { _backburner } from '@ember/runloop' ;
33import Ember from 'ember' ;
44
5+ import EmberApplicationInstance from '@ember/application/instance' ;
6+
57import { nextTick } from './-utils' ;
68import waitUntil from './wait-until' ;
79import { hasPendingTransitions } from './setup-application-context' ;
@@ -30,6 +32,31 @@ const _internalPendingRequests = (() => {
3032 return ( ) => 0 ;
3133} ) ( ) ;
3234
35+ if ( typeof jQuery !== 'undefined' && _internalPendingRequests ) {
36+ // This exists to ensure that the AJAX listeners setup by Ember itself
37+ // (which as of 2.17 are not properly torn down) get cleared and released
38+ // when the application is destroyed. Without this, any AJAX requests
39+ // that happen _between_ acceptance tests will always share
40+ // `pendingRequests`.
41+ //
42+ // This can be removed once Ember 4.0.0 is released
43+ EmberApplicationInstance . reopen ( {
44+ willDestroy ( ...args : any [ ] ) {
45+
46+ const internalPendingRequests = _internalPendingRequests ( ) ;
47+
48+ if ( internalPendingRequests === 0 ) { return ; }
49+
50+ jQuery ( document ) . off ( 'ajaxSend' , internalPendingRequests . incrementPendingRequests ) ;
51+ jQuery ( document ) . off ( 'ajaxComplete' , internalPendingRequests . decrementPendingRequests ) ;
52+
53+ internalPendingRequests . clearPendingRequests ( ) ;
54+
55+ this . _super ( ...args ) ;
56+ } ,
57+ } ) ;
58+ }
59+
3360let requests : XMLHttpRequest [ ] ;
3461
3562/**
Original file line number Diff line number Diff line change @@ -6,12 +6,6 @@ const debugTree = BroccoliDebug.buildDebugCallback('ember-test-helpers');
66module . exports = {
77 name : require ( './package' ) . name ,
88
9- included ( ) {
10- this . _super . included . apply ( this , arguments ) ;
11-
12- this . import ( 'vendor/monkey-patches.js' , { type : 'test' } ) ;
13- } ,
14-
159 treeForAddonTestSupport ( tree ) {
1610 // intentionally not calling _super here
1711 // so that can have our `import`'s be
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments