简体   繁体   中英

TypeScript - testing a single class in Angular2 project

I'm new to Angular2 and have been searching for this for a while. I come from a C# background and used unit tests there. I have searched for a while but didn't get to my target
My Setup: I'm using the AngularCLI

Problem:

how can I create / run a test that verifies the result without testing my whole project? assuming that I have this test

describe('AdderTest', () => {
        let adder:Adder = new Adder();
        it('should add correctly', () => {
            expect(adder.add(3,5)).toEqual(8);
        })
});

You can use fdescribe instead of describe for development purpose. This forces jasmine to run only this specific test and skips others. Just don't forget to return it back when you are done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM