Writing Unit Tests for Angular Components
Browser-based acceptance tests are slow and brittle. Even though you’ve eschewed starting an actual browser for each test by using PhantomJS, you still have to start our server and have it serve pages to the headless browser. Further, our tests rely on DOM elements and CSS classes to locate content used to verify behavior. You may need (or want) to make changes to the view that don’t break functionality, but break our tests.
Although we don’t want to abandon acceptance tests—after all, they are the only tests we have that exercise the system end to end—we need a way to test isolated bits of functionality (commonly called unit tests). In Rails, you have model tests and controller tests that allow you ...
Get Rails, Angular, Postgres, and Bootstrap, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.