What does npm mean by ‘Skipping failed optional dependency’?

This is not an error. It is a warning that fseventsd, which is Mac OS specific, cannot be installed on Linux. There is no need to be alarmed, and the package that needs fsevents will still work – that’s why it’s an optional dependency. Since many people are confused about this (particularly since this used … Read more

Failed: Unexpected directive ‘ContactDetailsComponent’ imported by the module ‘DynamicTestModule’. Please add a @NgModule annotation

Remove ContactDetailsComponent component from the import array and add it in the declaration array. Components are always placed in a declaration array and modules are placed in import array. Here is the solution: import { async, ComponentFixture, TestBed } from ‘@angular/core/testing’; import { AdditionalContactDetailsComponent } from ‘./additional-contact-details.component’; import { EdlInputModule, EdlIconModule, EdlMessagesModule } from ‘@fedex/ddt’; … Read more

Karma unit testing error: Unexpected value imported by the module. Please add a @NgModule annotation

You are injecting MatDialogRef in component: constructor(private dialogRef: MatDialogRef<Mytest1Component>) { } So the testBed expects the same to be injected as provider to the TestBed. Or you can also provide a MockDialogueService to it. beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ Mytest1Component ], providers: [ MatDialogRef ], }) .compileComponents(); }));

Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed. How to refactor and reduce the complexity

A little information on how cognitive complexity works and why you should keep it low First of all it is important to understand how “Cognitive Complexity” works as compared to “Cyclomatic Complexity“. Cognitive complexity takes into account the complexity perceived by the human brain. This is why it does not simply indicate the number of … Read more

Karma Jasmine – Uncaught TypeError: __webpack_require__(…).context is not a function

I had the same issue. For some reason, in our other app doing angular update automatically deleted some code in test.ts, namely: const context = require.context(‘./’, true, /\.spec\.ts$/); context.keys().forEach(context); and the declaration of require above that. I did that in my other app manually and so far it works. Maybe someone knows the reason for … Read more

Error: : fromEvent is not declared writable or has no setter

You need to spy on a property of rxjs. Using spyOnProperty will solve the error. Try this import * as rxjs from ‘rxjs’ import { of, fromEvent } from ‘rxjs’; spyOnProperty(rxjs, ‘fromEvent’).and.returnValue(of({})) you can also add to getter/setters using this like spyOnProperty(rxjs, ‘fromEvent’, ‘get’).and.returnValue(false) Hope this helps

Angular 2 Final Release Router Unit Test

For testing we now create a testing module using TestBed. We can use the TestBed#configureTestingModule and pass a metadata object to it the same way we would pass to @NgModule beforeEach(() => { TestBed.configureTestingModule({ imports: [ /* modules to import */ ], providers: [ /* add providers */ ], declarations: [ /* components, directives, and … Read more

Karma: use Windows’ Chrome from WSL

I found that if you create a C:\tmp\karma folder under Windows, this error goes away, and Chrome finds and uses this folder for temp files. You can also change the temporary folder that Chrome uses for its data by setting the TEMP environment variable like so: export TEMP=’/path/to/your/folder’ The important thing is that C:\path\to\your\folder must … Read more

What is the difference between fakeAsync and async in Angular testing?

tl;dr In almost all cases, they can be used interchangeably, but using fakeAsync()/tick() combo is preferred unless you need to make an XHR call, in which case you MUST use async()/whenStable() combo, as fakeAsync() does not support XHR calls. For the most part they can be used interchangeably. I can’t think of anything off the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)