有一些mocha测试需要先前函数调用的数据,但之后因为它使用了web服务,并且希望它在运行下一个测试之前确实等待预定的时间,例如:
var global;
it('should give some info', function(done) {
run.someMethod(param, function(err, result) {
global = result.global
done();
});
});
wait(30000); // basically block it from running the next assertion
it('should give more info', function(done) {
run.anotherMethod(global, function(err, result) {
expect(result).to.be.an('object');
done();
});
});
Run Code Online (Sandbox Code Playgroud)
任何想法,将不胜感激.谢谢!
我正在尝试编译一个打字稿文件,它不断从编译器中抛出这个错误:
error TS2339: Property 'payload' does not exist on type 'string | object'.
Property 'payload' does not exist on type 'string'.
有问题的代码:
decode(token: string): any {
const decodedJWT = jwt.decode(token, { complete: true });
const issuer = decodedJWT.payload.iss;
^^^^^^^^^
return {};
}
Run Code Online (Sandbox Code Playgroud)
我正在使用@types/jsonwebtoken库来定义类型。任何帮助将非常感激。