Skip to content

Instantly share code, notes, and snippets.

@Oleg-Sulzhenko
Last active February 27, 2019 17:20
Show Gist options
  • Save Oleg-Sulzhenko/49749ffb8e0b1350c1a36946272d6da1 to your computer and use it in GitHub Desktop.
Save Oleg-Sulzhenko/49749ffb8e0b1350c1a36946272d6da1 to your computer and use it in GitHub Desktop.
ngDocs => https://angular.io/guide/testing https://stackoverflow.com/questions/22093418/jasmine-unit-test-skipped-by-my-karma-configuration How to run specific test only - When using **iit** or **ddescribe**, you set focus only on this test/suite.
const bannerDe: DebugElement = fixture.debugElement;
const bannerEl: HTMLElement = bannerDe.nativeElement;
*ngDocs
Angular relies on the DebugElement abstraction to work safely across all supported platforms. Instead of creating an HTML element tree,
Angular creates a DebugElement tree that wraps the native elements for the runtime platform.
The nativeElement property unwraps the DebugElement and returns the platform-specific element object.
** The DebugElement has other methods and properties that are useful in tests, as you'll see elsewhere in this guide.
https://angular.io/guide/testing#bycss
** The server-side renderer might not support the full HTML element API. If it doesn't support querySelector, the previous test could fail.
The DebugElement offers query methods that work for all supported platforms. import { By } from '@angular/platform-browser';
const bannerDe: DebugElement = fixture.debugElement;
const paragraphDe = bannerDe.query(By.css('p'));
const p: HTMLElement = paragraphDe.nativeElement;
expect(p.textContent).toEqual('banner works!')
=========================================================
test doubles (stubs, fakes, spies, or mocks)
Дублери (англ. Test double) — спеціалізовані методи чи об'єкти, які використовуються при тестуванні систем,
в яких виникає необхідність взаємодії з зовнішніми об'єктами, наприклад: бази даних, файлова система,
мережеве з'єднання та тощо. При цьому дублер повинен реалізувати інтерфейс зовнішнього об'єкту та відповідати
всім вимогам, які висуваються до реального об'єкта.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment