typescript - 使用对象数组中的数据在循环中量角器 it() 规范
问题描述
我正在尝试使用规范(它)设置一个 e2e 测试套件来测试在应用程序中打开文件。我想稍后在每个测试规范上收集一些性能数据(基于文件大小、时间等)。
由于除了文件和相关属性之外,测试规范几乎相同,因此我使用了一个 json 对象(数据数组)来获取文件名。我尝试使用此处列出的解决方案。
我尝试使用此处提到的 jasmine-data-provider 遍历测试规范。但是规格被跳过了。
describe("App File Open", () => {
let fileNames: string[] = [];
const filePath: string = "common filepath for files"
beforeAll(() => {
fileNames = jsonFile["files"];
// ...
});
beforeEach(function (): void {
// ...
});
using(fileNames, (data: string) => {
it("open file " + data, () => {
// ...
inputElement.sendKeys(filePath + data);
// ...
});
});
afterEach(function (): void {
// ...
});
afterAll(function (): void {
// ...
});
});
测试跳过块而不拿起测试规范(它)。
“茉莉花开始
在 0 秒内执行 0 个规范中的 0 个成功。”
是否可以遍历规格?如果是这样,我在这里错过了什么?(抱歉,如果这是重复的)
解决方案
我不知道 jasmine-data-provider 但这个块
using(fileNames, (data: string) => {
it("open file " + data, () => {
// ...
inputElement.sendKeys(filePath + data);
// ...
});
});
在 之前进行评估fileNames = jsonFile["files"];
,因此fileNames
是一个空字符串。
推荐阅读
- python - 使用 pymatlab 从 Python 脚本调用 Matlab 函数
- python - 字典更新序列元素 #0 错误
- node.js - 无法理解异步/等待
- python - Google Cloud Dataflow Python SDK 更新
- c# - 嵌套列表和 Automapper.Map
- r - 在 Data.Table 中保留标签列时的行子集
- javascript - MobX:如何绑定@computed 函数(如@action.bound)?
- python - 将 DataFrame 列拆分为两个 + MultiIndex
- twitter-bootstrap-3 - 键盘选择后引导单选按钮组发布错误的值
- swift - Swift NumberOfRowsInSection void 函数中的意外非 void 返回值