Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

test(*): run class-related tests everywhere; fix eval syntax #15967

Merged
merged 1 commit into from
May 9, 2017

Conversation

mgol
Copy link
Member

@mgol mgol commented May 6, 2017

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Test fixes.

What is the current behavior? (You can also link to an open issue here)

There was a syntax error in class-related tests; the test wasn't failing only because it was disabled everywhere outside of Chrome and Chrome <59 incorrectly accepted it.

What is the new behavior (if this is a feature change)?

  1. Wrap an evaled class definition in parens; previously they weren't.
  2. The classes support test was modified to check not only if a class definition parses but also if it stringifies correctly which is required by AngularJS. This restriction disables class-related tests in current Firefox (53) but will work in v55 or newer.

Does this PR introduce a breaking change?

No.

Please check if the PR fulfills these requirements

Other information:

1. Wrap an evaled class definition in parens; previously they weren't; the test
   wasn't failing only because it was disabled everywhere outside of Chrome
   and Chrome <59 incorrectly accepted such input.
2. There's no reason to restrict class-related tests just to Chrome; now they
   run in every browser that supports ES6 classes. The classes support test
   was modified to check not only if a class definition parses but also if
   it stringifies correctly which is required by AngularJS. This restriction
   disables class-related tests in current Firefox (53) but will work in v55
   or newer.
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

My only concern is the following:

In case that our supportTests start returning false (so the tests are skipped), we might break the functionality but won't see any tests failures.

I would feel more comfortable if we had some way to essentially verify the supportTests. E.g. if we know that Chrome should support all features, have tests that verify the if (/chrome/.test(navigator.userAgent)) support.* === true. (Open to better ideas too 😃)

@gkalpak gkalpak added this to the Backlog milestone May 7, 2017
@mgol
Copy link
Member Author

mgol commented May 7, 2017

@gkalpak I tend to agree. While in code shipped to browsers support tests are much, much better than UA-sniffing (so that unknown environments with proper support works), in tests it may be better to UA-sniff to make sure that our assertions are correct.

Note that currently we have the classes support test but all its uses are additionally wrapped in a Chrome UA-check; the worse of both worlds. :D So this PR in its current form is an improvement anyway.

EDIT (I misread the comment): your suggestion to verify support test results in known browsers actually sounds better to me than any hardcoding in known enviros! I'll add that soon.

@Narretz
Copy link
Contributor

Narretz commented May 9, 2017

We could also create a "blacklist" of browsers we know will not support classes (basically IE). That way, every new browser is automatically assuned to support classes

@mgol
Copy link
Member Author

mgol commented May 9, 2017

It's not just IE, also old Safari/iOS (which we'll be testing for a while) and we might want to try running the tests on the Android Browser 4.0-4.3. For now it seems better IMO to just assert the results are what we expect them to be as we do in jQuery: https://github.com/jquery/jquery/blob/3.2.1/test/unit/support.js#L61-L235

@mgol
Copy link
Member Author

mgol commented May 9, 2017

I'd like to land this PR as-is, the new tests verifying support tests results seem like a separate thing (I can submit a PR for that shortly).

@gkalpak
Copy link
Member

gkalpak commented May 9, 2017

I am fine adding the support tests in a separate PR.

@Narretz
Copy link
Contributor

Narretz commented May 9, 2017

Me too!

@mgol mgol merged commit 30eb194 into angular:master May 9, 2017
@mgol mgol deleted the test-outside-chrome branch May 9, 2017 13:08
mgol added a commit that referenced this pull request May 9, 2017
1. Wrap an evaled class definition in parens; previously they weren't; the test
   wasn't failing only because it was disabled everywhere outside of Chrome
   and Chrome <59 incorrectly accepted such input.
2. There's no reason to restrict class-related tests just to Chrome; now they
   run in every browser that supports ES6 classes. The classes support test
   was modified to check not only if a class definition parses but also if
   it stringifies correctly which is required by AngularJS. This restriction
   disables class-related tests in current Firefox (53) but will work in v55
   or newer.

Closes #15967
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.

4 participants