问题描述
到目前为止,我阅读的大多数问题仅涉及在运行Protractor/vscode时尝试调试单元测试/e2e测试(或者更确切地说,如何使断点在vscode中工作)
Most of the questions I've read so far only deal with trying to debug the unit tests / e2e tests when running Protractor / vscode (or rather how to make the breakpoints work in vscode)
就我而言,我能够在我的e2e测试中放置断点,而vscode对此没有任何问题,但是问题是,一旦我进入 it()
函数,我就有了不知道如何访问/检查我的组件
In my case, I'm able to place breakpoints in my e2e tests and vscode have no issues with them, but the problem, once I'm inside the it()
function, I have no clue how to access/inspect my components
我知道e2e测试与组件无关,但是在这种情况下,我能够找到一个讨厌的bug,只有e2e测试才能捕获,我真的需要检查组件变量以了解发生了什么
I know e2e tests are not about components, but in this case, I was able to find a nasty bug that only e2e tests were able to catch, and I really need to inspect component variables to see what's going on
it('should do something with ProductComponent', () =>
{
// Code...
// Once I'm here, how can I inspect ProductComponent anyway??
}
例如,其中ProductComponent如下所示:
where, for example, ProductComponent looks like this:
@Component({
selector : 'app-product',
templateUrl: './product.component.html',
styleUrls : ['./product.component.css']
})
export class ProductComponent
{
productId: number;
productSKU: number;
// ...
}
推荐答案
尝试使用browser.pause()
或browser.explore()
方法.我认为explore
更适合您的需求.
Try browser.pause()
or browser.explore()
methods. I think that explore
fits more into your needs.
http://www.protractortest.org/#/api ?view = ProtractorBrowser.prototype.pause http://www.protractortest.org/#/api?view= ProtractorBrowser.prototype.explore
import {browser} from 'protractor';
describe('suite', () => {
it('test',() => {
browser.pause();
browser.explore();
});
});
这篇关于运行量角器时如何调试组件/打字稿代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!