Skip to content

Commit

Permalink
Gather list of deprecations by id and emit them at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Mar 24, 2021
1 parent e07895b commit d30d798
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ let asyncLeakageFailures = [];

_backburner.DEBUG = true;

let deprecationCounts = Object.create(null);

QUnit.done(function() {
if (moduleLoadFailures.length) {
throw new Error('\n' + moduleLoadFailures.join('\n'));
Expand All @@ -28,6 +30,25 @@ QUnit.done(function() {
if (asyncLeakageFailures.length) {
throw new Error('\n' + asyncLeakageFailures.join('\n'));
}

let entries = Object.keys(deprecationCounts)
.map(key => [key, deprecationCounts[key]])
.sort((a, b) => b[1] - a[1]);

if (deprecationCounts.size > 0) {
/* eslint-disable no-console */
let maxWidth = 0;
entries.forEach(([id]) => {
if (id.length > maxWidth) {
maxWidth = id.length;
}
});
console.log('Deprecation Counts');
entries.forEach(([id, count]) => {
console.log(id.padEnd(maxWidth), count);
});
/* eslint-enable no-console */
}
});

class TestLoader extends AbstractTestLoader {
Expand Down Expand Up @@ -99,6 +120,13 @@ registerDeprecationHandler((message, options, next) => {
next(message, options);
});

registerDeprecationHandler((message, options, next) => {
let count = deprecationCounts[options.id] || 0;
deprecationCounts[options.id] = count + 1;

next(message, options);
});

// Provide a way to squelch the this-property-fallback
if (typeof URLSearchParams !== 'undefined') {
let queryParams = new URLSearchParams(document.location.search.substring(1));
Expand Down

0 comments on commit d30d798

Please sign in to comment.