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

Explain the newEvent helper function used in the live example of Testing docs #23370

Open
keilla opened this issue Apr 13, 2018 · 13 comments
Open

Explain the newEvent helper function used in the live example of Testing docs #23370

keilla opened this issue Apr 13, 2018 · 13 comments

Comments

@keilla
Copy link
Contributor

@keilla keilla commented Apr 13, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[X] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

In Testing Section, there is a typo.
The example in Change an input value with dispatchEvent() section, in the test is showing

nameInput.dispatchEvent(newEvent('input'));

Expected behavior

nameInput.dispatchEvent(new Event('input'));

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Angular version: X.Y.Z


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@ngbot ngbot bot added this to the needsTriage milestone Apr 16, 2018
@marzann
Copy link

@marzann marzann commented Apr 17, 2018

Is this issue open for contribution?

@jenniferfell
Copy link
Contributor

@jenniferfell jenniferfell commented Apr 21, 2018

docsarea=testing
filename=guide/testing.md
URL=https://angular.io/guide/testing

@brandonroberts When you get a chance, would you look into this. The question is about the example code. Thanks!

@brandonroberts
Copy link
Contributor

@brandonroberts brandonroberts commented Apr 23, 2018

Hi @keilla! The code used there is not a typo. There is a newEvent helper function that's in the live example, but not explained in the documentation. I think it would be valuable to show it though to avoid confusion.

@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 9, 2018
@jenniferfell jenniferfell changed the title Documentation Typo Explain the newEvent helper function used in the live example of Testing docs May 9, 2018
@brandonroberts
Copy link
Contributor

@brandonroberts brandonroberts commented Jun 26, 2018

@marzann this issue is open for contribution. Would you like to submit a PR?

@maxterry
Copy link

@maxterry maxterry commented Aug 16, 2018

So far haven't been able to find any information on this random, basically un-duck-duck-go-able newEvent function that's mentioned, but never imported or explained, in the docs.

@maxterry
Copy link

@maxterry maxterry commented Aug 16, 2018

@brandonroberts Definitely looks to be a typo: shouldn't newEvent(...) just be new Event(...)?

@brandonroberts
Copy link
Contributor

@brandonroberts brandonroberts commented Aug 16, 2018

@1083 its not a typo, its not just exposed in the guide. The source for the example is here https://github.com/angular/angular/blob/master/aio/content/examples/testing/src/testing/index.ts#L23

@krzysztof-grzybek
Copy link
Contributor

@krzysztof-grzybek krzysztof-grzybek commented Oct 17, 2018

@brandonroberts As we can in comment above this method, it's created only for better compatibility between browsers:
Although officially deprecated, some browsers (phantom) don't accept the preferred "new Event(eventName)"

Since angular tests are run on Chrome by default, maybe we don't need it any more? I think it might be confusing, especially if not documented.

@jakpaw
Copy link
Contributor

@jakpaw jakpaw commented Aug 2, 2019

Hey, I would like to submit my first PR for this issue

andrewasche added a commit to andrewasche/angular that referenced this issue May 7, 2020
Trying to resolve the following issue: . . . 

Explain the newEvent helper function used in the live example of Testing docs angular#23370 . . . . angular#23370
@andrewasche andrewasche mentioned this issue May 7, 2020
0 of 14 tasks complete
@andrewasche
Copy link

@andrewasche andrewasche commented May 7, 2020

sorry, I think i misunderstood. I don't know if any work is needed here

@kapunahelewong
Copy link
Contributor

@kapunahelewong kapunahelewong commented May 7, 2020

@andrewasche, you could re-open your PR and instead of changing the code, you could explain the newEvent() function per this comment #23370 (comment), if you would like.

PowerKiKi added a commit to PowerKiKi/angular that referenced this issue May 22, 2020
Because PhantomJS has been deprecated since March 2018, and `newEvent`
is very confusing for newcomers that read the testing documentation,
we remove it entirely, and instead assume most, if not all, newcomers
will run tests in Chrome as it is the default.

Fixes angular#23370
@andrewasche
Copy link

@andrewasche andrewasche commented May 30, 2020

Thanks for the encouragement. I tried again to explain that newEvent is not a typo, I reopened my PR and got it right this time.

@andrewasche
Copy link

@andrewasche andrewasche commented Jun 2, 2020

next Try. . .

I created a branch and tried to do it properly

Here is my PR:
#37386

PowerKiKi added a commit to PowerKiKi/angular that referenced this issue Jun 2, 2020
Because PhantomJS has been deprecated since March 2018, and `newEvent`
is very confusing for newcomers that read the testing documentation,
we remove it entirely, and instead assume most, if not all, newcomers
will run tests in Chrome as it is the default.

Fixes angular#23370
PowerKiKi added a commit to PowerKiKi/angular that referenced this issue Jun 2, 2020
Because PhantomJS has been deprecated since March 2018, and `newEvent`
is very confusing for newcomers that read the testing documentation,
we remove it entirely, and instead assume most, if not all, newcomers
will run tests in Chrome as it is the default.

Fixes angular#23370
PowerKiKi added a commit to PowerKiKi/angular that referenced this issue Jun 2, 2020
Because PhantomJS has been deprecated since March 2018, and `newEvent`
is very confusing for newcomers that read the testing documentation,
we remove it entirely, and instead assume most, if not all, newcomers
will run tests in Chrome as it is the default.

Fixes angular#23370
gkalpak added a commit to PowerKiKi/angular that referenced this issue Jul 9, 2020
Because PhantomJS has been deprecated since March 2018, and `newEvent`
is very confusing for newcomers that read the testing documentation,
we remove it entirely, and instead assume most, if not all, newcomers
will run tests in Chrome as it is the default.

Fixes angular#23370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.