Angular testing made easy – Clarity Design System – Medium

Angular testing made easy @EudesPV  #AngularJS #Nodejs #JavaScript #Testing

  • So what’s the most efficient way to centralize that boilerplate, so that your actual spec files can focus on the unit tests themselves?This article will show you a neat solution to this problem, using two little-known features: Jasmine’s user context and Typescript’s ability to type this.
  • There are two main advantages to this approach over local variables: it helps fight the memory leaks that keep creeping up on large projects’ tests, and it also offers a very easy way to have your beforeEach and it in two different files, which is much harder to set up with local variables.CAUTION: We are using a plain function() {} here, rather than the very useful () = {} arrow notation from Typescript.
  • One of the recommended patterns (and the one we use the most, by far, in Clarity) is to use a “test host” component which includes the actual component to test in its template:This example makes a few assumptions to keep it simple: the templates are all inline or inlined at build time so we don’t need to MyUserComponent doesn’t depend on other components, … Feel free to adapt to your specific use case.Introducing the TestContextIf we want to extract all the boilerplate into a separate file, we need to decide what the type of the user context passed around by Jasmine should be.
  • The one difference is that we’re getting the tested directive through the injector, rather than componentInstance, once again to be able handle attribute directives and components at the same time.The final spec fileLet’s remove all the boilerplate from the user component’s spec file and use our brand new context:It’s now entirely comprised of the unit tests, no distractions or verbose setup to go through.
  • That’s a win!To improve this further, you could easily:include the setup() call at the root of the tests to have it always be available,allow passing extra directives to declare or modules to import, in case your component depends on other ones,add additional shortcuts to the TestContext interface,throw explicit errors when trying to test with a host component that does not contain the directive,…In our case, for instance, we have a shortcut to get providers from the tested element’s injector.

If you’re here, you have probably already read the Angular documentation on testing, and maybe have written a few tests for your own project. If you have not, I can only suggest you do so, because…
Continue reading “Angular testing made easy – Clarity Design System – Medium”

A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3): Mark Myers: 9781523986460: Amazon: Books

Buy A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3) on Amazon.com ✓ FREE SHIPPING on qualified orders
Continue reading “A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3): Mark Myers: 9781523986460: Amazon: Books”

Node.js in Practice: Alex R. Young, Marc Harter: 9781617290930: Amazon: Books

Buy Node.js in Practice on Amazon.com ✓ FREE SHIPPING on qualified orders
Continue reading “Node.js in Practice: Alex R. Young, Marc Harter: 9781617290930: Amazon: Books”

A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3): Mark Myers: 9781523986460: Amazon: Books

Buy A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3) on Amazon.com ✓ FREE SHIPPING on qualified orders
Continue reading “A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3): Mark Myers: 9781523986460: Amazon: Books”

A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3): Mark Myers: 9781523986460: Amazon: Books

Buy A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3) on Amazon.com ✓ FREE SHIPPING on qualified orders
Continue reading “A Smarter Way to Learn jQuery: Learn it faster. Remember it longer. (Volume 3): Mark Myers: 9781523986460: Amazon: Books”

AngularJS 2.0 From The Beginning

#AngularJS2.0 From The Beginning - Pipes - Day 8 by @debasiskolsaha cc @CsharpCorner

  • Now, in this article, I will discuss about pipes, one of the new flavors of Angular 2 architectures.
  • In Angular 2.0, the pipes are the modernized version of the filters.
  • x have been converted as pipes in Angular 2.0 with some new pipes.
  • The table given below shows a comparison of pipes or filters in both Angular 1.
  • Thus, in this article, we will discuss how to use Angular 2.0 predefined pipes and also discuss how to create a custom pipe in Angular 2.0.

In this article, we will discuss about pipes in Angular 2.0.
Continue reading “AngularJS 2.0 From The Beginning”

Jumping into ng2 with Angular CLI

  • For this we invited an experienced tutor that will introduce you to the power of the Angular CLI!
  • This is also a great opportunity to connect with other Angular developers, whether you are one yourself or just want to find out what it is all about.
  • Angular2 has been production ready for about 5 months now, and along with all of the other exciting improvements it offers, there is also an official CLI tool for generating and maintaining projects, currently in a late beta release.
  • The angular-cli is a great way to hit the ground running with your first Angular2 project for both beginners and experienced Angular developers.
  • Having learned the hard way that his passion lies in product development he now specializes in helping others develop their projects efficiently and effectively using best practices and the latest production ready technologies.

Second month of 2017, and time for our second Angular talk this year!
We know that a lot of you are interested in hands-on activities, and even more want to start now with Angular 2. For this we invit
Continue reading “Jumping into ng2 with Angular CLI”