1
我想評估是否從一個表(table.getData())是一個2D數組返回的數據包含另一個數組。斷言數組包括Chai
在控制檯中,期望的數據出現在從table.getData()調用返回的2D數組中,但斷言失敗。
this.Then(/^I see my account balances as follows:$/, function (tableData, done) {
var balanceAggregationPage = new BalanceAggregationPage(this.app.pagesContainer),
table = balanceAggregationPage.getAccountsTable();
var rows = tableData.getRows();
rows.shift();
var actualBalances = [];
rows.syncForEach(function (item) {
var row = item.raw();
row[7] = moment(parseInt(row[7], 10)).format('DD MMM YYYY hh:mm');
actualBalances.push(row);
});
exp(table.getData()).to.eventually.include(actualBalances).notify(done);
});
任何人都可以幫忙嗎? 謝謝
這其實很好。我不知道。我正在刪除我的答案,以支持你的答案。謝謝! –
對我而言,不幸的是我的數據是作爲黃瓜TableData對象傳遞給我的:thenCatch:[Function], thenFinal:[Function], addCallback_:[Function]}作爲數組 – Joly
哦,我被你在問題中討論數組的事實所誤導。 事實上,如果你的數據是一個對象而不是數組,那麼它將不起作用,因爲** include僅適用於字符串或數組**。不幸的是,我根本不知道黃瓜,所以我不知道它是如何工作的。 也許你可以將你的TableData對象轉換爲*真實*數組? – noKid