...

/

Perform an Action Before and After Each Test

Perform an Action Before and After Each Test

Learn to use Jasmine hooks to perform actions before or after tests.

In the previous lesson, we saw that there were clock install and uninstall actions that were done as part of the spec:

it('should return 7 for a date 7 days ago', () => {
    const clock = jasmine.clock();
    ... // test code skipped

    clock.uninstall();
});

That logic is not a part of the test. It’s also repeated verbatim for each test. We can do better.

Jasmine hooks

There are a few functions we ...

Access this course and 1400+ top-rated courses and projects.