Image for post
Image for post
Photo by Jiri Sifalda on Unsplash

What happened that made TypeScript viable for me and worth migrating paypal-scripts for.

Note: There was a lot of misunderstanding about this post so I want to make it clear that most of PayPal still uses JavaScript and this post is just to announce that PayPal engineers can now very easily choose between TypeScript and JavaScript for their projects without fiddling around with tooling.

NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent. Subscribe to get more content like this earlier right in your inbox! 💌

… here it is!

At PayPal…

Image for post
Image for post
Photo by Vincent Guth on Unsplash

A few questions and answers about testing in JavaScript

The Assert(js) Conference is just about a month away. I’m really excited about attending, speaking, and workshopping at a conference all about testing JavaScript.

In preparation for the conference, the organizers invited us speakers to answer a few questions about testing. Here are my answers!

What testing tools and/or workflow do you use?

I’ve used pretty much every testing tool for JavaScript there is. I started with QUnit, then used Jasmine, Mocha, sprinkled some Karma to run things, and then I had to figure out how to make things work with babel and webpack, then throwing in code coverage…

Image for post
Image for post

The live broadcast podcast all about JavaScript

I’m pleased to announce JavaScript Air! This is a live video broadcast podcast all about JavaScript and the web and the first episode, “The past, present, and future of JavaScript,” will be with BrendanEich. I couldn’t be more stoked to have the original creator of JavaScript on for the first episode of this new show.

Add the event to your calendar by RSVPing to the Google+ event.

Image for post
Image for post

UPDATE: I now try to avoid using testing lifecycle hooks or nesting describes at all. Listen to me talk about it for 3 minutes here. In fact, now that I’m using Jest (learn Jest), I don’t even use describe either. I find it’s much better this way. But if you want to use lifecycle hooks anyway, this blogpost is still relevant.

With mocha (and jasmine) you have a few hooks into the testing lifecycle: describe, before, after, beforeEach, afterEach, and it. What do these all mean? When do I use one over another? What do I put in each of…

I’m converting my project to use webpack for a ton of reasons. It’s awesome. This has given me the opportunity to reflect on the relationship between angular modules and npm modules and I think I’ve determined what I believe to be the best way for angular module developers to show the npm angular developers some love. (And, I encourage you to join the promised land)

Step 1

Create a dist directory where you place a file that ships everything you need to use the module (unminified). Then set your package.json’s “main” property to this file. …

Image for post
Image for post

I was intrigued by the slides from Vjeux entitled “React: CSS in JS” (which is very good stuff and I would encourage you to read through it). I decided to see what it would look like to create something similar with Angular. turns out it’s not that bad and it’s actually kind of refreshing. I think I’ll keep looking into this…

Here’s a demo that I built when experimenting with the concept:

So there’s definitely room for additional abstractions here to make it easier to manage, but I can see some serious potential with this approach and will definitely investigate…

For the non-trivial Angular Application

If you’ve worked on a sizeable AngularJS application, you’ll discover that while Angular’s digest cycle is awesome, it can also make your app seem sluggish as it grows and that digest cycle takes longer. So it becomes important to watch your watchers because even though one wont really cause an issue, the more you have, the worse it gets.

In an app I’m working on at work, we have areas of the app that can get a rather large watch count fast. Most pages sit at around 2,000, but some grow up to over 20,000…

Reduce AngularJS Watch Count…

What makes AngularJS more slow than anything else I’ve encountered is having a ton of watchers. For those of you who aren’t familiar with how AngularJS does its two-way databinding, essentially you tell Angular to watch something for changes, and Angular will check it over and over and over and over and over…. and over. Most of the time, the browser is fast enough that this is not a big issue, but many people have found that this can be a real issue as the app (and number of watchers) grows.

Angular adds a watcher to the digest cycle for…

Browserify? Require.js? Concat w/ Sourcemaps? An alternative approach…

IMPORTANT NOTE: I now use webpack and, as awesome as this was, it has some serious shortcomings. My experience with webpack has been SO much better! I even made an series on Angular and Webpack for Modular Applications.

I just read a medium post by @dickeyxxx about simplifying your Angular app’s script loading by simply leveraging Angular’s built-in module system and simply concatenating your source for dev and making source maps in favor over browserify or requirejs which can be more complicated. …

Kent C. Dodds

Making software development more accessible · Husband, Father, Latter-day Saint, Teacher, OSS, GDE, @TC39 · @PayPalEng @eggheadio @FrontendMasters · #JS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store