想在 mocha 测试函数中添加额外的上下文,但 addContext 不起作用。
describe('Test', function () {
before('before', function () {
addContext(this, 'context before all'); <-- Not working
});
after('after', function () {
addContext(this, 'context after all'); <-- Not working
});
it('Call just a working test API', function () {
var test=this;
addContext(this, 'Hello1 (this) !!!!'); <-- Working
addContext(test, 'Hello2 (test) !!!!'); <-- Working
unirest.post('http://mockbin.com/request')
.headers({'Accept': 'application/json', 'Content-Type':
'application/json'})
.send({ "parameter": 23, "foo": "bar" }).end(function (response) {
console.log('In reponse function');
addContext(test, 'Hello3 !!!!'); <-- Not working
addContext(test, '' …Run Code Online (Sandbox Code Playgroud)