vendredi 13 avril 2018

Angular 5 Testing returns errors

I am having some troubles with an Angular Project. I am just learning Angular and encountering all sort of errors along the way.

My project is compiling and running fine but whenever I am trying to run an "ng test" to see if my test succeed I am getting all sort of errors back. They look like this:

ERROR in ./node_modules/webdriver-js-extender/node_modules/selenium-webdriver/firefox/extension.js
Module not found: Error: Can't resolve 'fs' in '

or

ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in 

And so on. I read about the fs that I was supposed to add target: 'node' in the webpack config. When I did an ng Eject the webpack config file had this

...
"node": {
    "fs": "empty",
...

My test looks something like this, I'm only attaching the part where errors have started:

it('should send credentials on submit', () => {
  let fixture = TestBed.createComponent(LoginComponent);
  let component: LoginComponent = fixture.componentInstance;
  let element = fixture.nativeElement;

  fixture.detectChanges();

  element.username = expectedUsername;


  element.query(by.id('login-username')).value = expectedUsername;
  element.query(by.id('login-username')).dispatchEvent(new Event('input'));
  element.query(by.id('login-password')).value = expectedPassword;
  element.query(by.id('login-password')).dispatchEvent(new Event('input'));

Aucun commentaire:

Enregistrer un commentaire