From 5a0f90e038c54d796a93401f6247e7fa261ffdbe Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Mon, 20 Mar 2017 19:28:07 -0700 Subject: [PATCH] test(smokehouse): fix flakiness of dom-size expectation (#1881) adds support for `RegExp` tests in smokehouse expected values --- lighthouse-cli/test/smokehouse/pwa-expectations.js | 2 +- lighthouse-cli/test/smokehouse/smokehouse.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lighthouse-cli/test/smokehouse/pwa-expectations.js b/lighthouse-cli/test/smokehouse/pwa-expectations.js index 834b2b42de9e..aec232e57afd 100644 --- a/lighthouse-cli/test/smokehouse/pwa-expectations.js +++ b/lighthouse-cli/test/smokehouse/pwa-expectations.js @@ -83,7 +83,7 @@ module.exports = [ extendedInfo: { value: { 1: {value: '20'}, - 2: {snippet: 'Element with most children:\nul#versionlist.canaryisdev'} + 2: {snippet: /ul.versionlist/} } } }, diff --git a/lighthouse-cli/test/smokehouse/smokehouse.js b/lighthouse-cli/test/smokehouse/smokehouse.js index 1014e725b1d7..6ab358150fa8 100755 --- a/lighthouse-cli/test/smokehouse/smokehouse.js +++ b/lighthouse-cli/test/smokehouse/smokehouse.js @@ -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,