1
votes

Started with Angular E2E, and tried to test multiple files (divided the test cases module wise).

Changes made in protractor.conf.js

specs: [
     "./src/login/login.component.e2e-spec.ts",
     "./src/customs-portal/home.component.e2e-spec.ts",
],

this runs the test cases of both files in the same sequence.

In the home test case file I have written

beforeAll(() => {
     homePage= new HomePage();
     helperService = new HelperService();

     CSS = homePage.CSS;
     helperService.navigate("/home");

     helperService.skipIntro();
});

i navigate to /home, on home page there is skip button that i clicks to avoid intro phase about the page. Here is how skipIntro function looks like

async skipIntro(): Promise<any> {
    const _skipBtn = await element(by.css(this.CSS.SKIP_INTRO));
    console.log("HelperService -> _skipBtn", _skipBtn);
    if (_skipBtn) {
        _skipBtn.click();
    }
}

but it shows error and fails the test case

it("dummy test always paas", async () => {
        expect(true).toEqual(true);
});

here is the error

- Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping.  See http://git.io/v4gXM for details"

here is helperService.navigate

navigate(path: string): promise.Promise<any> {
        return browser.get(path);
}

any help on this, not much experience on Angular E2E.

3

3 Answers

1
votes

Try this it should work

     beforeAll(async () => {
     homePage= new HomePage();
     helperService = new HelperService();
     CSS = homePage.CSS;

    await helperService.navigate("/home");
    await  helperService.skipIntro();
});

async skipIntro(): Promise<any> {
 const _skipBtn =await element(by.css(this.CSS.SKIP_INTRO));
    console.log("HelperService -> _skipBtn", _skipBtn);
    if (_skipBtn) {
        await _skipBtn.click();
    }
}

async navigate(path: string): promise.Promise<any> {
        await return browser.get(path);
}

async skipIntro(): Promise<any> {
    const _skipBtn = await element(by.css(this.CSS.SKIP_INTRO));
    console.log("HelperService -> _skipBtn", _skipBtn);
    if (_skipBtn) {
        await _skipBtn.click();
    }
}

async navigate(path: string): promise.Promise<any> {
        await return browser.get(path);
} 
0
votes

By looking at the error, I am assuming that the application under test is not Angular application. Protractor is mostly used to test angular applications but to test non-angular applications you can do following configuration change and you probably won't get this error

browser.waitForAngularEnabled(false);

This will disable searching for angular components in application and tests will get executed.

-1
votes

seems like async and control flow is mixed that seems to be an issue