Testing Angular
  • Overview
  • Overview
  • 1. Create a new Angular CLI application
  • 2. Run default tests
  • 3. Review the Angular CLI directory and testing tools set up
  • 4. Jasmine tests
  • 5. Add simple test
  • 6. Add simple failing test
  • 7. Add another test to check a property
  • 8. Test the Component logic using a mocked up Service
  • 9. Test the Component logic using SpyOn
  • 10. TestBed and Fixtures
Powered by GitBook
On this page

4. Jasmine tests

Jasmine is an open source testing framework from Pivotal Labs that uses behaviour-driven notation resulting in a fluent and improved testing experience.

Main concepts:

  1. Suites — describe(string, function) functions, take a title and a function containing one or more specs.

  2. Specs — it(string, function) functions, take a title and a function containing one or more expectations.

  3. Expectations — are assertions that evaluate to true or false. Basic syntax reads expect(actual).toBe(expected)

  4. Matchers — are predefined helpers for common assertions. Eg: toBe(expected), toEqual(expected). Find a complete list here.

Previous3. Review the Angular CLI directory and testing tools set upNext5. Add simple test

Last updated 6 years ago