lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 136 forks source link

Testing if an element is disabled on the DOM? #185

Closed kamok closed 7 years ago

kamok commented 7 years ago

Trying to test if a button is disabled. I was able to select the button in question by doing:

let button = fixture.nativeElement.querySelectorAll('button')[0]

** if there's a better way to select buttons, please link me to the reading. Have been trying to find some for a while.

Then, when I do button.isEnabled(), it gives me a no method error. I got the idea to use isEnabld() here.

I would appreciate it if someone can point me to some documentation to get better at unit testing. I've been reading Angular 2 materials, but I find them often to be not applicable to this test suite.

Thanks for reading.

lathonez commented 7 years ago

I usually test the css class (e.g use Angular's disabled class in the selector).

Again you'll get a much better response on stack overflow.

On 3 Dec 2016 03:06, "Ka Mok" notifications@github.com wrote:

Trying to test if a button is disabled. I was able to select the button in question by doing:

let button = fixture.nativeElement.querySelectorAll('button')[0]

** if there's a better way to select buttons, please link me to the reading. Have been trying to find some for a while.

Then, when I do button.isEnabled(), it gives me a no method error. I got the idea to use isEnabld() here http://stackoverflow.com/questions/21432339/how-to-check-if-an-element-is-enabled .

I would appreciate it if someone can point me to some documentation to get better at unit testing. I've been reading Angular 2 materials, but I find them often to be not applicable to this test suite.

Thanks for reading.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lathonez/clicker/issues/185, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5tSA3SSkMSlhbH14T5DADlFY7gxmzrks5rEHpYgaJpZM4LC8IJ .

kamok commented 7 years ago

@lathonez I think there's a higher possibility that people who use your starter app to ask the same questions. Almost all of my Ionic 2 questions are dead quiet on Stack. Thanks. Closing.

lathonez commented 7 years ago

Interesting thanks. I didn't know ionic was so dead on stack. Most of the questions (this included) are relevant for ng2 imo.

I don't have time to support the level of general unit testing questions I get on here any longer. Nor am I qualified by contrast with the ng2 community on stack overflow.

My hope was that by referring people to stack they'd get good answers in a timely fashion.

I guess this is more fallout from ionic not supporting any form of testing..

Will have a think on how to proceed.

On 5 Dec 2016 22:06, "Ka Mok" notifications@github.com wrote:

@lathonez https://github.com/lathonez I think there's a higher possibility that people who use your starter app to ask the same questions. Almost all of my Ionic 2 questions are dead quiet on Stack. Thanks. Closing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lathonez/clicker/issues/185#issuecomment-264877344, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5tSCNEpL7TKG2ec-QE5BCxDKkwHi6jks5rFChogaJpZM4LC8IJ .

lathonez commented 7 years ago

191