se6
v1.0.0
Published
Software Engineering 6
Downloads
2
Readme
se6 -- Software Engineering 6
BDD style expect test framework !
Example
File: test/expectTest.js
let se6 = require('../src/index')
let {expect} = se6
describe('se6.expect', function() {
it('number test', function() {
expect(2).to.be.a('number')
})
it('array test', function() {
let a = [1,2,3]
expect(a).contain(2)
expect(a).to.contain(1)
expect(a).to.not.contain(5)
expect(a).all((i)=>a.indexOf(i)>=0)
expect(a).any((i)=>i===2)
})
it('object test', function() {
let o = {name:'ccc'}
expect(o).to.contain('name').that.is.a('ccc')
})
it('pass test', function() {
let o = {name:'ccc'}
expect(o).to.pass((o)=>o.name==='ccc')
})
})
test:
$ mocha
se6.expect
√ number test
√ array test
√ object test
√ pass test
8 passing (50ms)
支持中文語法的 BDD
File: test/expectChinese.js
let se6 = require('../src/index')
let {希望, 願, 確認, 驗證} = se6
describe('se6.expect 中文測試', function() {
it('number test', function() {
希望(2).是('number')
})
it('array test', function() {
let a = [1,2,3]
願(a).包含(2)
驗證(a).包含(1)
確認(a).不.包含(5)
願(a).每個((i)=>a.indexOf(i)>=0)
})
it('object test', function() {
let o = {name:'ccc'}
希望(o).包含('name').那個.是('ccc')
})
it('pass test', function() {
let o = {name:'ccc'}
確認(o).通過((o)=>o.name==='ccc')
})
})
Test :
$ mocha
se6.expect 中文測試
√ number test
√ array test
√ object test
√ pass test