Skip to content

Commit

Permalink
test(smokehouse): fix flakiness of dom-size expectation (#1881)
Browse files Browse the repository at this point in the history
adds support for `RegExp` tests in smokehouse expected values
  • Loading branch information
patrickhulce authored and paulirish committed Apr 22, 2017
1 parent a54a664 commit 65ff089
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lighthouse-cli/test/smokehouse/pwa-expectations.js
Expand Up @@ -83,7 +83,7 @@ module.exports = [
extendedInfo: {
value: {
1: {value: '20'},
2: {snippet: 'Element with most children:\nul#versionlist.canaryisdev'}
2: {snippet: /ul.versionlist/}
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion lighthouse-cli/test/smokehouse/smokehouse.js
Expand Up @@ -111,9 +111,13 @@ function findDifference(path, actual, expected) {
return null;
}

if (typeof actual === 'string' && expected instanceof RegExp && expected.test(actual)) {
return null;
}

// If they aren't both an object we can't recurse further, so this is the difference.
if (actual === null || expected === null || typeof actual !== 'object' ||
typeof expected !== 'object') {
typeof expected !== 'object' || expected instanceof RegExp) {
return {
path,
actual,
Expand Down

0 comments on commit 65ff089

Please sign in to comment.