Thursday, 2 January 2020

How to test the existence of a route in Angular using Jasmine?

I'm trying to write a test that checks for the existence of a route using Jasmine for Angular application:

import { routes } from './app-routing.module';
import { UsersComponent } from './users/users.component';

describe('routes', () => {
    it('should contain route for /users', () => {
        const expectedRoute = { path: 'users', component: UsersComponent };
        expect(routes).toContain(expectedRoute);
    });
});

but the test fails (probably because of object equality in Javascript How object equality checks work in Javascript?)

How to modify the test to make it work?



from How to test the existence of a route in Angular using Jasmine?

No comments:

Post a Comment