About Jasmine

Jasmine

First, a few things that are important to know about Jasmine:

  • describe blocks define a test suite and each it block is for an individual test.

  • beforeEach runs before each test and is used for the setup part of a test.

  • afterEach runs after each test and is used for the teardown part of a test.

  • You can also use beforeAll and afterAll, and these run once before or after all tests.

  • You test an assertion in Jasmine with expect and using a matcher like toBeDefined, toBeTruthy, toContain, toEqual, toThrow, toBeNull… For example: expect(myValue).toBeGreaterThan(3);

  • You can do negative assertion with not: expect(myValue).not.toBeGreaterThan(3);

  • You can also define custom matchers.

Last updated