Answer the question
In order to leave comments, you need to log in
How to solve problems with e2e testing of a large project on Angular (4)?
Good day,
there is a fairly large project that is written in Angular (4). Now there is a task to cover the entire e2e project and unit tests. Decided to start with e2e. I looked at all the necessary dependencies and settings, putting the latest version next to it via Angular Cli. I registered a simple test, not serious, just checking the performance, but in the end even it does not work.
There are 2 files in the /e2e directory:
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return 'Welcome to app!';
}
}
import { AppPage } from './app.po';
describe('Project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
console.log('======================');
console.log(page.getParagraphText());
expect(page.getParagraphText()).toEqual('Welcome to app!');
});
});
E/protractor - Could not find Angular on page localhost:49152 : retries looking for angular exceeded
Project App
✗ should display welcome message
- Failed: Angular could not be found on the page localhost:49152 If this is not an Angular application, you may need to turn off waiting for Angular.
Answer the question
In order to leave comments, you need to log in
As a result, I had the following problem: the front communicates with the back through nginx, and when the application is initialized, I have a request for the back. Naturally, when running the tests, a server was raised to localhost:n-port, which could not communicate with the backend. As a result of the request, a 500 arrived during initialization and the test failed.
If anyone has the same problem because of the back, when nginx resolves everything, then for the tests you need to register a proxy. In short, next to package.json we create a file "proxy.conf.json", we write there:
{
"/api": {
"target": "http://НужныйАдрес:НужныйПротокол",
"secure": false
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question