Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(smokehouse): fix flakiness of smokehouse dom-size expectation #1881

Merged
merged 1 commit into from Mar 21, 2017

Conversation

patrickhulce
Copy link
Collaborator

adds RegExp smokehouse to boot :)

@brendankenny brendankenny changed the title test(smokehouse): fix flakiness of smokehouse test(smokehouse): fix flakiness of smokehouse dom-size expectation Mar 21, 2017
@@ -111,6 +111,10 @@ function findDifference(path, actual, expected) {
return null;
}

if (expected instanceof RegExp && expected.test(actual)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected.test() will do actual.toString() internally, so this check should be good for any value of actual, but if it fails this check, typeof expected will still be 'object', so it could pass the conditional below and then try to recurse on the regexp object instead of returning the difference. This could lead to a false positive result since Object.keys(/ul.versionlist/) is [], so any value of actual that has typeof 'object' will pass. e.g. findDifference('path', {}, /whatever/) will find no difference.

Simplest thing would be to also add || expected instanceof RegExp to the conditional below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although there is also the minuscule chance that actual.toString() could yield a string that somehow passes expected.test(), so you may also want to add a typeof actual === 'string' above and below (or rearrange somehow) if that's not a feature we want to support :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprised I don't see a RegExp.isRegExp() proposed anywhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? :P

well expected instanceof RegExp won't work if through some ridiculously circuitous process you're writing expectations values with a RegExp object from another realm, so the "real" way to check is like the old isArray check of Object.prototype.toString.call(expected) === '[object RegExp]'.

I would have thought someone, somewhere would have proposed RegExp.isRegExp() like Array.isArray() to TC39 at some point, but I couldn't find any record of such a thing :)

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! Just need to handle the corner case, I think. Clearly we need smoke test tests :)

@@ -111,6 +111,10 @@ function findDifference(path, actual, expected) {
return null;
}

if (expected instanceof RegExp && expected.test(actual)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprised I don't see a RegExp.isRegExp() proposed anywhere

@brendankenny
Copy link
Member

how was this flaking, incidentally? What string was being generated instead?

@brendankenny
Copy link
Member

brendankenny commented Mar 21, 2017

how was this flaking, incidentally? What string was being generated instead?

from a recent run:

difference at dom-size.extendedInfo.value[2].snippet:
found 'Element with most children: ul#versionlist.canaryisdev',
expected 'Element with most children: ul#versionlist'.

@patrickhulce
Copy link
Collaborator Author

Never did I expect so many comments for this... haha

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/🌋🚬🔥♨️/ LGTM

@brendankenny brendankenny merged commit 7824c3f into master Mar 21, 2017
@brendankenny brendankenny deleted the fix_smoke branch March 21, 2017 02:28
paulirish pushed a commit that referenced this pull request Apr 22, 2017
adds support for `RegExp` tests in smokehouse expected values
paulirish pushed a commit that referenced this pull request Apr 22, 2017
adds support for `RegExp` tests in smokehouse expected values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants