我有以下代码:
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')
})
})
})
当我运行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)
但我希望所有测试都被跳过。所以,问题是:
答案 0 :(得分:1)
Mocha似乎不支持它,它被视为&#34;功能&#34;。
请参阅:https://github.com/mochajs/mocha/issues/2683
可以通过
解决before(function () {
this.test.parent.pending = true;
this.skip();
});