我已经使用jasmine和chai为我的nodejs应用程序创建了一些测试。我期待使用CI构建在TFS中发布测试结果。有人可以指导我如何去做。
我写的测试示例
import chai from 'chai';
import sinon from 'sinon';
import financialMapper from "../map/mappers/party-financials.mapper";
import * as _ from 'lodash';
var assert = chai.assert;
var expect = chai.expect;
let financials = { key: 160233,
data:
[ { companyId: 160233,
dataItemName: 'Cash and Cash Equivalents, Beginning of Period',
dataItemId: 2055,
dataItemvalueUSD: 207217000,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Preferred Dividend and Other Adjustments',
dataItemId: 97,
dataItemvalueUSD: 405000,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Basic Earnings Per Share - Total',
dataItemId: 3523,
dataItemvalueUSD: 0.43728,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Net Property Plant And Equipment',
dataItemId: 1004,
periodTypeId: 4,
dataItemvalueUSD: 123269000,
fiscalYear: 2016,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Accounts Receivable, Total',
dataItemId: 1021,
dataItemvalueUSD: 892289000,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Net Income - (IS)',
dataItemId: 15,
dataItemvalueUSD: 65517000,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Accounts Payable, Total',
dataItemId: 1018,
dataItemvalueUSD: 246670000,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 },
{ companyId: 160233,
dataItemName: 'Interest Expense',
dataItemId: 208,
dataItemvalueUSD: -17878000,
fiscalYear: 2016,
periodTypeId: 4,
fiscalQuarter: 4 }]}
describe('party financials mapper test suit:', function () {
it('should return an array of financials items', function () {
let doc = financialMapper.map(financials).value[0]
assert.isArray(doc);
});
it('should return financials with period id equal to 4', function () {
let doc = financialMapper.map(financials).value[0]
assert.equal(doc[0].historical[0].periodTypeId,4);
});
it('should return financials item with name equal to : <Interest Expense>', function () {
let docs= financialMapper.map(financials).value[0]
let doc = _.find(docs, (item)=>{
return item.name==='Interest Expense'
})
assert.isTrue(doc.name==='Interest Expense');
});
it('should return financials item with data item id equal to: <208>', function () {
let docs= financialMapper.map(financials).value[0]
let doc = _.find(docs, (item)=>{
return item.name==='Interest Expense'
})
assert.equal(doc.dataItemId,208);
});
it('should return financials item with current value equal to :<-17878000>', function () {
let docs= financialMapper.map(financials).value[0]
let doc = _.find(docs, (item)=>{
return item.name==='Interest Expense'
})
assert.equal(doc.current,-17878000);
});
});
答案 0 :(得分:0)
之前我使用过this个包。该示例显示了如何为量角器设置它,但您可以使用karma或您正在使用的任何测试运行器执行相同的操作。只需将其设置为记者,以便创建xml文件,然后添加构建步骤以发布结果。