February 2019
Beginner
694 pages
18h 4m
English
As seen in our first simple test, Jasmine uses a fluent syntax to allow us to attach Jasmine matchers after the expect(...) statement. In our first test, we used the .toBeDefined matcher. Jasmine, however, has a wide range of matchers that can be used within tests, and also allows us to write and include custom matchers. Let's take a quick look at some of these matchers:
it("expect value toBe(2)", () => {
let twoValue = 2;
expect(twoValue).toBe(2);
})
Here, we are using the .toBe matcher to test that the value of the twoValue variable is indeed 2.
it("expect string toContain value ", () => {
let testString = "12345a";
expect(testString).toContain("a");
});
In this test, we are using the toContain matcher to test that the "12345a" ...
Read now
Unlock full access