Angular 2 Testing – Async function call – when to use

async will not allow the next test to start until the async finishes all its tasks. What async does is wrap the callback in a Zone, where all asynchronous tasks (e.g. setTimeout) are tracked. Once all the asynchronous tasks are complete, then the async completes. If you have ever worked with Jasmine outside out Angular, … Read more

Error: You need to include some adapter that implements __karma__.start method

It does seem like this is a very general error, however in my case the problem was either that I didn’t run karma start from the correct folder, or that I didn’t restart it after changing the configuration. I’ll leave this question open and hopefully it can become a resource for others who experience this … Read more

No provider for “framework:jasmine”! (Resolving: framework:jasmine)

I had the same error after creating a new project the yeoman angular generator (yo angular). The solution for me was adding “karma-jasmine” to the devDependencies in packages.json and running “npm install” again. npm install karma-jasmine –save-dev This solved the error message “No provider for “framework:jasmine”!” I also had to add a karma browser launcher … Read more

Found the synthetic property @enterAnimation. Please include either “BrowserAnimationsModule” or “NoopAnimationsModule” in your application. Angular4

Future readers: you can also get this exact error, when you forget to place animations: [ <yourAnimationMethod()> ] on your @Component ts file. that is if you’re using [@yourAnimationMethod] on the HTML template, i.e. angular animations.

How do I debug a “[object ErrorEvent] thrown” error in my Karma/Jasmine tests?

FYI: you can find the exact error thrown just by open DevTools Console once your tests are running. As a quickfix you can try to run your tests without sourcemaps: CLI v6.0.8 and above –source-map=false CLI v6.0.x early versions –sourceMap=false CLI v1.x –sourcemaps=false Shortcut ng test -sm=false might also work There is an open issue … Read more

Angular Karma Jasmine Error: Illegal state: Could not load the summary for directive

You passed HeroDetailComponent to TestBed.createComponent() without declaring the component first: TestBed.configureTestingModule({ imports: [AppModule, CommonModule, FormsModule, SharedModule, HeroRoutingModule, ReactiveFormsModule ], providers: [ {provide: APP_BASE_HREF, useValue: “https://stackoverflow.com/”} ], declarations: [HeroDetailComponent] }).compileComponents(); Hope it helps. Update for following errors in your test: Added some more imports (just take your HeroModule as a blueprint because that’s basically what you … Read more

Expect Arrays to be equal ignoring order

Edit Jasmine 2.8 adds arrayWithExactContents that will succeed if the actual value is an Array that contains all of the elements in the sample in any order. See keksmasta’s answer Original (outdated) answer If it’s just integers or other primitive values, you can sort() them before comparing. expect(array1.sort()).toEqual(array2.sort()); If its objects, combine it with the … Read more

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