传递class
作为参数以访问静态方法。 Evaluate似乎没有按原样传递它。我调试了这个似乎有效参数的line,但当我调用resolve method
时,它会抛出错误
无法读取未定义
的属性'resolve'
该类只包含简单的静态方法
class App {
public static resolve() { return true };
}
测试如下
//abc.test.ts
it('should contain "abc" text in Href', (done) => {
nightmare
.goto("abc.com")
.evaluate((driver: any) => {
console.log('driver', driver.resolve()); also is there a way to console.log in evaluate?
return document.getElementById("a").textContent;
}, App)
.end()
.then((response: any) => {
expect(response).to.have.containIgnoreSpaces("abc");
done();
})
.catch((error: any) => console.log("Error", error));
});
运行测试的npm命令
set DEBUG=nightmare && mocha --recursive --require jsdom-global/register --require ts-node/register --require babel-core/register tests/*