【问题标题】:TypeScript - testing a single class in Angular2 projectTypeScript - 在 Angular2 项目中测试单个类
【发布时间】:2017-02-11 05:18:35
【问题描述】:

我是 Angular2 的新手,并且一直在寻找这个。 我来自 C# 背景并在那里使用过单元测试。我已经搜索了一段时间,但没有达到我的目标
我的设置: 我正在使用 AngularCLI

问题:

如何在不测试整个项目的情况下创建/运行验证结果的测试? 假设我有这个测试

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

【问题讨论】:

    标签: angular typescript jasmine


    【解决方案1】:

    出于开发目的,您可以使用 fdescribe 代替 describe。这迫使 jasmine 只运行这个特定的测试并跳过其他测试。完成后别忘了把它还回去。

    【讨论】:

    • 我很抱歉这么新,你能告诉我使用哪个命令吗? ng test 运行 Karma 并打开浏览器
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-15
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    相关资源
    最近更新 更多