BeforeAll 未定义(旧茉莉花)

BeforeAll is not defined (old jasmine)

我刚刚安装了 Protractor v2.0.0。我试图将 beforeAll 添加到测试中,但出现错误

ReferenceError: beforeAll is not defined

查看堆栈跟踪,我发现 jasmine 1.3.1 是量角器的子模块:

C:\Users\bmackey\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:913:21

beforeAll 是在 jasmine 2.1 中引入的。我试过 npm i -g jasmine-before-all 无济于事。我怎样才能让这个功能发挥作用?

Protractor 仍在默认使用 jasmine1。您必须在配置中设置 jasmine 版本

framework: 'jasmine2',

您可以在 reference configuration file

中找到更多信息

此外,如果您出于某种原因想继续使用 jasmine-1.x,请使用 jasmine-beforeAll 包。它提供相同的 beforeAllafterAll 挂钩。