Tag: Mocha

React allows you to create components that will render UI for your application. If your UI is of any complexity, you’ll likely want to test that it functions correctly and allows for future refactors. There are numerous ways to do this. One way that you might appreciate is using jsdom, an in-JavaScript implementation of the DOM.

When working inside your test suite, it’s often the case that you don’t want to run all of your tests. Mocha has a great mechanism that allows you to easily specify what exactly you want run. This can help make your processes such as TDD faster and more focused.

When you’re trying to test your authenticated URLs via supertest, there are just a couple things you’ll need to do that aren’t spelled out in the docs.

When you test your AngularJs code, you need to explicitly inject the services that your controllers and modules require. It has its own special syntax. It requires mocking. You’ll see a slightly different syntax than you may have expected.

Did you write your source code as JavaScript AMD modules in RequireJs? Do you want to test them in real browsers? Do you want the flexibility of using Mocha or Jasmine? This is the moment you’ve been waiting for.

Testacular is a “spetacular test runner for JavaScript” that was written to support the AngularJs project. It is valuable because it will run your tests in real browsers. This is important for front-end code that relies on browser globals such as window (eg, if you use jQuery) or that manipulates the DOM (which could vary browser to browser).

Client-side JavaScript testing is a somewhat crazy space. Some have even called it “insane” and taken drastically different routes than what follows. But we’re gonna see if we can power through, and Testacular will help us get the job done.