generator-angular2-library icon indicating copy to clipboard operation
generator-angular2-library copied to clipboard

Generate tests for each generated piece

Open NathanWalker opened this issue 9 years ago • 17 comments

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

NathanWalker avatar Dec 08 '15 23:12 NathanWalker

@NathanWalker — Totally agree! :+1:

jvandemo avatar Dec 09 '15 07:12 jvandemo

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?

jvandemo avatar Dec 09 '15 08:12 jvandemo

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 < [email protected]> 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 .

NathanWalker avatar Dec 09 '15 08:12 NathanWalker

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

ocombe avatar Dec 09 '15 08:12 ocombe

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

@ocombe — Thank you, that would be great!

jvandemo avatar Dec 09 '15 09:12 jvandemo

@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?

jvandemo avatar Dec 09 '15 09:12 jvandemo

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

ocombe avatar Dec 09 '15 09:12 ocombe

@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!!

jvandemo avatar Dec 09 '15 10:12 jvandemo

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 ;)

yllieth avatar Oct 13 '16 14:10 yllieth

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

ocombe avatar Oct 13 '16 14:10 ocombe

@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!

moses-aronov avatar Apr 09 '17 07:04 moses-aronov

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

ocombe avatar Apr 10 '17 22:04 ocombe

@ocombe Thank you

moses-aronov avatar Apr 11 '17 02:04 moses-aronov

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

ocombe avatar Apr 11 '17 06:04 ocombe

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

@ocombe — Thank you for sharing your thoughts 👍

jvandemo avatar Apr 11 '17 19:04 jvandemo

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

kktam avatar Aug 31 '17 03:08 kktam

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

jvandemo avatar Aug 31 '17 04:08 jvandemo