jvandemo / generator-angular2-library

Yeoman generator to create an Angular library
MIT License
752 stars 122 forks source link

Generate tests for each generated piece #1

Open NathanWalker opened 8 years ago

NathanWalker commented 8 years ago

To make testing libs easier, we should add testing infrastructure and have the generator automatically generate generic tests for the various generated pieces.

jvandemo commented 8 years ago

@NathanWalker — Totally agree! :+1:

jvandemo commented 8 years ago

As explained by @Ocombe in Angular Air episode 43: currently setting up testing is a bit hacky and only Jasmine is supported.

Should we wait till the Angular team comes up with better support (e.g. mocha, chai) or should we go ahead and already implement what is available right now?

NathanWalker commented 8 years ago

I feel like there's enough, especially for testing services and/or pipes, that it would be beneficial to set something up now so lib authors could start building with this generator. The generator can then improve as support gets better over time.

I see this generator as a catalyst to help more devs assist in building libs for the angular2 landscape. Let's help make the beta phase and final release more appealing with a growing list of 3rd party libraries, great job on all this!

On Wed, Dec 9, 2015 at 12:14 AM Jurgen Van de Moere < notifications@github.com> wrote:

As explained by @Ocombe https://github.com/Ocombe in Angular Air episode 43 https://www.youtube.com/watch?v=OCLzt0a53Uw: currently setting up testing is a bit hacky and only Jasmine is supported.

Should we wait till the Angular team comes up with better support (e.g. mocha, chai) or should we go ahead and already implement what is available right now?

— Reply to this email directly or view it on GitHub https://github.com/jvandemo/generator-angular2-library/issues/1#issuecomment-163146924 .

ocombe commented 8 years ago

I'll try to write an article on testing with ng2 next week, that might help

jvandemo commented 8 years ago

I'll try to write an article on testing with ng2 next week, that might help

@ocombe — Thank you, that would be great!

jvandemo commented 8 years ago

@NathanWalker, @ocombe: I once write a plunk for Angular 1.x that made it possible to write unit tests in Plnkr: http://plnkr.co/edit/IwQx9y7VdN7SiDeawVSC

It would be great if we could have something similar for Angular 2 as a starting place to experiment with boilerplate code that we can then put into the generator.

Do you think it is technically possible for us to come up with a plunk to write/run unit tests in Angular 2?

ocombe commented 8 years ago

yes, I'm almost sure that I saw one recently

jvandemo commented 8 years ago

@Ocombe — Awesome, that would be great as a starting point. Will try to find it. Feel free to post a link here if you find it. Thanks!!

yllieth commented 7 years ago

Hi !! Did you find a way to add unit tests in your generator ? I still have some trouble to make it by my own ... Big thanks ;)

ocombe commented 7 years ago

You can look for my testing setup on https://github.com/ocombe/ng2-translate it doesn't use this seed though, so maybe it isn't what you're looking for, but it should help nonetheless

moses-aronov commented 7 years ago

@ocombe Do you mind sharing the seed you used for ng2-translate? I am having trouble integrating karma. I am new to angular, and I created a couple of libraries in my current app and I wanted to extract them but still be able to use the tests. I like the way your project is structured too!

ocombe commented 7 years ago

I didn't used any seed, I made it up myself as the time went. If you need a seed for library you can look at this one: https://github.com/preboot/angular-library-seed/ Otherwise read this very good article: http://blog.mgechev.com/2017/01/21/distributing-an-angular-library-aot-ngc-types/

There also was a talk at ng-conf by the Angular team about how to setup a library for distribution, the video is not available yet but should be in the next few days. They didn't talk about testing though. The demo app that they used for the talk was https://github.com/jasonaden/simple-ui-lib

moses-aronov commented 7 years ago

@ocombe Thank you

ocombe commented 7 years ago

One more for the road, by the angular team as well: https://github.com/filipesilva/angular-quickstart-lib

jvandemo commented 7 years ago

Jason's talk is now available at https://www.youtube.com/watch?v=unICbsPGFIA.

@ocombe — Thank you for sharing your thoughts 👍

kktam commented 7 years ago

@jvandemo have this feature been now built? is this file part of the fix?

jvandemo commented 7 years ago

@kktam — No, currently only jest is implemented. Karma + jasmine have not been added yet. Thanks!