I have an Angular 9 app. It has 2 projects in it. If I run e2e tests. it runs on the whole app. i.e. if I look for h1 tag, it takes the default app root h1 tag. I cannot make it access project 1 or project 2. How do I add / write an e2e test , to test the nav menu in project 1 for example?
This is my folder structure:
-- whole-angular
-- e2e
-- projects
--project-a
--e2e (I have manually put this here as not sure if I need to, where to put it)
--src
--nav.bar.e2e-spec.ts
--nav-bar.po.ts
--protractor.conf.js
--tsconfig.e2e.json
--src
-- app (and then all the usually project/app files)
--project-b
--src
am thinking I need to set something inside the global e2e config file? Maybe the angular.json file. Or even the e2e config inside the actual project?
nav-bar.po-ts
import { browser, by, element, ElementFinder, promise } from 'protractor';
export class NavBar {
navigateToBio():promise.Promise<any> {
return browser.get('/bio');
}
getBioPage():promise.Promise<any> {
return element(by.css('h1')).getText();
}
}
nav-bar.e2e-spec.ts
import { NavBar } from './nav-bar.po';
import { browser, protractor, element, by } from 'protractor';
describe('Nav bar', () => {
let navBar: NavBar = new NavBar();
beforeEach(() => {
navBar.navigateToLead();
});
it('should display the bio page', () => {
navBar.navigateToBio();
expect(navBar.getBioPage()).toEqual("bio page");
});
});
Error:
In the console it says:
(passes the default e2e test there) workspace-project App √ should display welcome message
(fails my one) Nav bar × should display the lead page - Expected 'Welcome to whole-angular!' to equal 'bio page'.
Any more info you need let me know :-)