File tree Expand file tree Collapse file tree 3 files changed +22
-45
lines changed
addon-test-support/@ember/test-helpers Expand file tree Collapse file tree 3 files changed +22
-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 EmberApplication from '@ember/application' ;
6+
57import { nextTick } from './-utils' ;
68import waitUntil from './wait-until' ;
79import { hasPendingTransitions } from './setup-application-context' ;
@@ -30,6 +32,26 @@ 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+ EmberApplication . reopen ( {
44+ willDestroy ( ) {
45+ jQuery ( document ) . off ( 'ajaxSend' , _internalPendingRequests . incrementPendingRequests ) ;
46+ jQuery ( document ) . off ( 'ajaxComplete' , _internalPendingRequests . decrementPendingRequests ) ;
47+
48+ _internalPendingRequests . clearPendingRequests ( ) ;
49+
50+ this . _super ( ...arguments ) ;
51+ } ,
52+ } ) ;
53+ }
54+
3355let requests : XMLHttpRequest [ ] ;
3456
3557/**
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