How to debug component/typescript code when running Protractor

喜欢而已 提交于 2019-12-23 02:25:16

问题


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)

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

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??
}

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;
    
    // ...
}

回答1:


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();
    });
}); 


来源:https://stackoverflow.com/questions/45142915/how-to-debug-component-typescript-code-when-running-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!