kha*_*iuk 5 tdd mocha.js node.js
我有下面的一些代码:
const assert = require('assert')
describe('server', function() {
before(function() {
// HACK: skip the tests in staging environment until we find to provide db in it
if(process.env.NODE_ENV === 'staging') {
this.skip();
}
});
it('list request', function() {
assert.fail('fails wo db')
})
describe('detail requests', function() {
it('some arguments', function() {
assert.fail('fails wo db')
})
})
})
Run Code Online (Sandbox Code Playgroud)
当我跑步时NODE_ENV='staging' npm test:
> @ test /Users/kharandz/Projects/mocha-bug
> mocha
server
- list request
detail requests
1) some arguments
0 passing (10ms)
1 pending
1 failing
1) server detail requests some arguments:
AssertionError: 'fails wo db' undefined undefined
at Context.<anonymous> (test/sample.spec.js:16:14)
Run Code Online (Sandbox Code Playgroud)
但我希望跳过所有测试。那么,问题是:
Mocha 似乎不支持它,它被认为是一个“功能”。
请参阅: https: //github.com/mochajs/mocha/issues/2683
可以通过以下方式解决
before(function () {
this.test.parent.pending = true;
this.skip();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2876 次 |
| 最近记录: |