File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ export function deprecateSimple(name, msg) {
6060 hooks . deprecationHandler ( name , msg ) ;
6161 }
6262 if ( ! deprecations [ name ] ) {
63- warn ( msg ) ;
63+ warn ( msg + '\n' + new Error ( ) . stack ) ;
6464 deprecations [ name ] = true ;
6565 }
6666}
Original file line number Diff line number Diff line change 11import { module , test } from '../qunit' ;
2- import { deprecate } from '../../lib/utils/deprecate' ;
2+ import { deprecate , deprecateSimple } from '../../lib/utils/deprecate' ;
33import { hooks } from '../../lib/utils/hooks' ;
44
55module ( 'deprecate' ) ;
@@ -16,3 +16,34 @@ test('deprecate', function (assert) {
1616
1717 assert . expect ( 0 ) ;
1818} ) ;
19+
20+ test ( 'deprecateSimple includes a stack trace and warns once' , function ( assert ) {
21+ var oldSuppressDeprecationWarnings = hooks . suppressDeprecationWarnings ,
22+ oldWarn = console . warn ,
23+ warnings = [ ] ;
24+
25+ hooks . suppressDeprecationWarnings = false ;
26+ console . warn = function ( msg ) {
27+ warnings . push ( msg ) ;
28+ } ;
29+
30+ try {
31+ deprecateSimple (
32+ 'testing deprecateSimple' ,
33+ 'testing simple deprecation'
34+ ) ;
35+ deprecateSimple (
36+ 'testing deprecateSimple' ,
37+ 'testing simple deprecation'
38+ ) ;
39+ } finally {
40+ console . warn = oldWarn ;
41+ hooks . suppressDeprecationWarnings = oldSuppressDeprecationWarnings ;
42+ }
43+
44+ assert . equal ( warnings . length , 1 , 'warns once for each named deprecation' ) ;
45+ assert . ok (
46+ warnings [ 0 ] . indexOf ( 'testing simple deprecation\n' ) !== - 1 ,
47+ 'includes a stack trace after the message'
48+ ) ;
49+ } ) ;
You can’t perform that action at this time.
0 commit comments