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

6. Add simple failing test

  • Add another test, this time with a failing assumption.

src/app/app.component.spec.ts
describe(`Component: App Component`, () => {
  it('add 1+1 - PASS', () => {
        expect(1 + 1).toEqual(2);
  });
  
  it('add 1+1 - FAIL', () => {
        expect(1 + 1).toEqual(42);
  });
});
  • run ng test again. This time, you should see one failure.

Previous5. Add simple testNext7. Add another test to check a property

Last updated 6 years ago