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(1882): add test case #1905

Merged
merged 2 commits into from
Sep 21, 2018
Merged

test(1882): add test case #1905

merged 2 commits into from
Sep 21, 2018

Conversation

mgred
Copy link
Contributor

@mgred mgred commented Sep 16, 2018

Purpose (TL;DR) - mandatory

See: #1882, sinonjs/samsam#37

Background (Problem in detail) - optional

Solution - optional

This test is passing for me locally

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm run test-node

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

* add test case provided in sinonjs#1882
* change some eslint config to match test:
** class definitions are not enabled in ecmaVersion 5,
** addint Proxy as global

See: sinonjs#1882, sinonjs/samsam#37
@coveralls
Copy link

coveralls commented Sep 16, 2018

Pull Request Test Coverage Report for Build 2676

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.356%

Totals Coverage Status
Change from base Build 2673: 0.0%
Covered Lines: 2043
Relevant Lines: 2097

💛 - Coveralls

Copy link
Member

@mroderick mroderick left a comment

Choose a reason for hiding this comment

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

Thank you fro your pull request.
I have a few comments related to using ES5.1 instead of ES6.

.eslintrc.yml Outdated

plugins:
- ie11
- local-rules

parserOptions:
Copy link
Member

Choose a reason for hiding this comment

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

Sinon is an ES5.1 project, as described in CONTRIBUTING.md.

If we allow ES6 syntax, we drop support for IE11 and older Safari. I don't think we're quite there yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, Change this to fit the example. I will revert


describe("#1882", function () {
it("should use constructor name when checking deepEquality", function () {
class ClassWithoutProps {}
Copy link
Member

Choose a reason for hiding this comment

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

class is an ES6 convenience over using prototype. This means that you can achieve the same using prototype.

function ClassWithoutProps(){}
ClassWithoutProps.prototype.constructor = ClassWithoutProps;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh, yeah let me change this...

it("should use constructor name when checking deepEquality", function () {
class ClassWithoutProps {}
const arg1 = new ClassWithoutProps(); //arg1.constructor.name === ClassWithoutProps
const arg2 = new Proxy({}, {}); //arg2.constructor.name === Object
Copy link
Member

Choose a reason for hiding this comment

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

Can this test be done without using Proxy, which is from ES6 and is not supported in IE11?

Perhaps create AnotherClassWithoutProps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true I will rewrite with to your suggestion, which makes the most sense I think

@mgred
Copy link
Contributor Author

mgred commented Sep 17, 2018

Thanks for all your suggestions, and sorry for ignoring the ES5 restriction for IE11. I keep learning.

* Rewert config to support IE11 again
* Adopt changes to test to be ES5
@mroderick mroderick merged commit f6ee6ac into sinonjs:master Sep 21, 2018
@mroderick
Copy link
Member

Thank you 👍

@fatso83
Copy link
Contributor

fatso83 commented Sep 21, 2018

WebWorker test crashed on Node 10 for some unknown reason after merge to master.

@fatso83
Copy link
Contributor

fatso83 commented Sep 24, 2018

This test started failing on IE 11 in our Sauce Labs suite last Friday after merge. It was "hidden" from view due to the webworker test also failing on Circle CI@Node 10 (for some unknown reason I am trying to look into).

See the logs (overview):

    "result": "....\n\n  1572 passing (9s)\n  8 pending\n  1 failing\n\n  1) issues\n       #1882\n         should use constructor name when checking deepEquality:\n     AssertionError: [assert.same] 5 expected to be the same object as undefined\n     at referee.fail (Unknown script code:6419:9)\n     at ctx.fail (Unknown script code:6280:17)\n     at assertion (Unknown script code:6288:13)\n     at referee[type][name] (Unknown script code:6315:9)\n     at Anonymous function (Unknown script code:24983:13)\n     at callFn (Unknown script [truncated]",

@fatso83
Copy link
Contributor

fatso83 commented Sep 24, 2018

I found more information on this and detailed this out in this comment sinonjs/samsam#41 (comment). It seems like samsam already failed 4 tests when running in IE11 (not known to us) before merging sinonjs/samsam#38. That didn't matter much, as it seems we did not rely on those parts of samsam.

But the change to constructor equality broke 3 additional tests on IE 11, and this did break things in Sinon 😿 Would you like to have a go at trying to get them passing, @mgred? I can supply you with Sauce Labs credentials (mail in profile).

@fatso83
Copy link
Contributor

fatso83 commented Sep 24, 2018

I used mochify --consolify index.html lib/*test.js to produce a html file with the tests and set up a web server to serve it. Then used Sauce Labs "Live Testing" feature and the sc binary to live test in the IE11 debugger.

bug samsam ie11

Turns out no stack or message props are created for errors when they are not thrown in IE, meaning two errors are otherwise identical if not thrown.

@mroderick Suggestions for fix? They are deeply equal, but maybe it's ok to assume that all errors are thrown? Then I could simply replace new Error() with createError() which does a try/catch/return.

@mgred
Copy link
Contributor Author

mgred commented Sep 24, 2018

@fatso83 puh that escalated quickly, Sorry guys. Sure, I will have a look and see what I can find out.

@fatso83
Copy link
Contributor

fatso83 commented Sep 24, 2018

@mgred you absolutely don't have to, and it's our own fault that we didn't run these tests on our supported browsers to begin with. It's hard to know you are breaking compatibility with some semi-ancient browser when no-one tells you :-) As already stated, 4 tests were already failing on IE11 prior to this, so we should try to tackle them before you look at the new ones, in case they're related. I'll file an issue.

@mroderick
Copy link
Member

@mroderick Suggestions for fix? They are deeply equal, but maybe it's ok to assume that all errors are thrown? Then I could simply replace new Error() with createError() which does a try/catch/return.

Where does createError() come from? I can't seem to find it in sinon source.

@fatso83
Copy link
Contributor

fatso83 commented Sep 25, 2018

@mroderick I made it up. I guess "with createError() which does a try/catch/return." should be "with a sort of createError() function that could do a try/catch/return". And zooming between various related repos is not what I do best, apparently, as I failed to mention that all of the code I am talking about belongs (/would belong) in the samsam repo.

@fatso83
Copy link
Contributor

fatso83 commented Sep 25, 2018

ps. suggest we continue any discussion in sinonjs/samsam#42

@mgred
Copy link
Contributor Author

mgred commented Sep 25, 2018

@fatso83 let me see what I can find out

franck-romano pushed a commit to franck-romano/sinon that referenced this pull request Oct 1, 2019
* test(1882): add test case

* add test case provided in sinonjs#1882
* change some eslint config to match test:
** class definitions are not enabled in ecmaVersion 5,
** addint Proxy as global

See: sinonjs#1882, sinonjs/samsam#37

* fix(1882): changes according to review

* Rewert config to support IE11 again
* Adopt changes to test to be ES5
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

4 participants