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

Added matchers .toBeCloseTo and .toMatch #1277

Merged

Conversation

valerybugakov
Copy link
Contributor

No description provided.

@ghost ghost added the CLA Signed ✔️ label Jul 10, 2016
@cpojer
Copy link
Member

cpojer commented Jul 11, 2016

Please rebase :)

@valerybugakov valerybugakov force-pushed the to_match_to_be_close_to_matchers branch from 0d1052c to 2a701fb Compare July 11, 2016 09:45
@valerybugakov
Copy link
Contributor Author

@cpojer done 😊

@cpojer
Copy link
Member

cpojer commented Jul 11, 2016

Seems like there are some failures on travis?

if (
!(typeof expected === 'string') &&
!(Object.prototype.toString.call(expected) === '[object RegExp]')
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cpojer do you have any idea why the first variant might fail for some cases? In dev tools for the case

  expect(diff('a', 'a')).toMatch(/no visual difference/);

expected.constructor prints [Function: RegExp] but expected.constructor === RegExp is false.

Copy link
Contributor

Choose a reason for hiding this comment

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

#1275
that should fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it 👍
rebased and revoked this fix

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! sorry you had to go through this :)

@valerybugakov valerybugakov force-pushed the to_match_to_be_close_to_matchers branch from 2e35a6e to 4ee552a Compare July 11, 2016 18:03
@@ -109,6 +109,35 @@ const matchers: MatchersObject = {
`'${expected}' (using <=)`;
return {message, pass};
},

toBeCloseTo(actual: number, expected: number, precision: number) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should probably be precision?: number, because it's optional

@valerybugakov valerybugakov force-pushed the to_match_to_be_close_to_matchers branch from 070a1cb to e223d2b Compare July 11, 2016 20:30
@valerybugakov valerybugakov force-pushed the to_match_to_be_close_to_matchers branch from e223d2b to 47d78ec Compare July 12, 2016 08:12
@aaronabramov aaronabramov merged commit 41ba3eb into jestjs:master Jul 12, 2016
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants