Jasmine 在某些测试中避免 beforeEach

标签 jasmine

有没有办法只针对某些测试(“it” block )不执行 beforeEach 函数。假设我有 10 个 it block ,我不希望为其中两个 block 执行 beforeEach。可能吗?

最佳答案

您可以将要与 beforeEach 一起运行的规范分组到单独的 describe 中:

it('should 1...', function () {});
it('should 2...', function () {});

describe('group', function () {

    beforeEach(function () {
        // ...
    });

    it('should 3...', function () {});
    it('should 4...', function () {});

    // ...
});

关于Jasmine 在某些测试中避免 beforeEach,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31182170/

相关文章:

angular - 在 Angular 中,spyOn 无法使用异步管道

angular - Angular 中十进制验证器的单元测试

node.js - Jasmine - 如何从规范覆盖范围中排除 node_modules

javascript - Jasmine 测试元素是否淡出

javascript - AngularJs Jasmine 单元测试中的 $httpBackend

angular - 有没有办法在 Angular 中测试 Observable 订阅?

javascript - Firefox 配置文件设置在带有 selenium webdriver 配置的 Protractor 中抛出错误

rest - 有什么方法可以确保 frisby.js 测试 API 调用按顺序进行?

javascript - Angular 如何知道 $httpBackend 正在替换 Angularjs 测试中的 $http ?

javascript - Protractor :计算所有超链接并在页面上测试它们