Skip to content

Commit e1e5d0c

Browse files
rwjblueRobert Jackson
authored and
Robert Jackson
committed
Prevent window.Ember deprecation on Ember 3.27+.
Accessing `window.Ember` (e.g. without importing) will issue a deprecation in Ember 3.27 and higher, and ultimately removed in Ember 4. (cherry picked from commit cd0fa8b)
1 parent 1b5a1a3 commit e1e5d0c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/utilities/ember-app-utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ function contentFor(config, match, type, options) {
129129
break;
130130
case 'test-body-footer':
131131
content.push(
132-
`<script>document.addEventListener('DOMContentLoaded', function() { Ember.assert('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".', EmberENV.TESTS_FILE_LOADED);});</script>`
132+
`<script>
133+
document.addEventListener('DOMContentLoaded', function() {
134+
if (!EmberENV.TESTS_FILE_LOADED) {
135+
throw new Error('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".');
136+
}
137+
});
138+
</script>`
133139
);
134140

135141
break;

tests/unit/utilities/ember-app-utils-test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ describe('ember-app-utils', function () {
211211
let output = contentFor(config, defaultMatch, 'test-body-footer', defaultOptions);
212212

213213
expect(output, 'includes `<script>` tag').to.equal(
214-
`<script>document.addEventListener('DOMContentLoaded', function() { Ember.assert('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".', EmberENV.TESTS_FILE_LOADED);});</script>`
214+
`<script>
215+
document.addEventListener('DOMContentLoaded', function() {
216+
if (!EmberENV.TESTS_FILE_LOADED) {
217+
throw new Error('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".');
218+
}
219+
});
220+
</script>`
215221
);
216222
});
217223
});

0 commit comments

Comments
 (0)