ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - lazycuh/angular-testing-kit: A set of convenient utilities to make Angular testing with Jasmine and Karma simpler.
A set of convenient utilities to make Angular testing with Jasmine and Karma simpler. - lazycuh/angular-testing-kit
Visit Site

GitHub - lazycuh/angular-testing-kit: A set of convenient utilities to make Angular testing with Jasmine and Karma simpler.

GitHub - lazycuh/angular-testing-kit: A set of convenient utilities to make Angular testing with Jasmine and Karma simpler.

angular-testing-kit

A set of convenient utilities to make Angular testing with Jasmine and Karma simpler.

Table of contents

Angular version compatibility

  • 16+

Installation

  • npm
    npm i -S @lazycuh/angular-testing-kit
    
  • pnpm
    pnpm i -S @lazycuh/angular-testing-kit
    
  • yarn
    yarn add @lazycuh/angular-testing-kit
    

assertThat()

This assertion function accepts either a string or a DebugElement, it returns an assertion object that can be used to check for different conditions. The returned assertion object has the following methods:

.doesNotExist()

Will pass if no element with the provided class name exists in document.body.

Example

assertThat('.hello-world').doesNotExist();

.exists()

Will pass if an element with the provided class name exists in document.body.

Example

assertThat('.hello-world').exists();

.hasInnerHtml()

Will pass if an element with the provided class name has the provided inner HTML string.

Example

assertThat('.hello-world').hasInnerHtml('<span>Hello World</span>');

.hasTextContent()

Will pass if an element with the provided class name has the provided string as its text content.

Example

assertThat('.hello-world').hasTextContent('Hello World');

.hasTextContentMatching()

Will pass if an element with the provided class name whose text content matches the provided value. This function also accepts a RegExp to perform custom matching.

Example:

assertThat('.hello-world').hasTextContentMatching(/hello\s+world/i);

delayBy()

Returns a promise that will resolve after the provided milliseconds. Useful for when you need to wait for some asynchronous process to complete before proceeding.

Example

await delayBy(500);

extractTextContent()

Returns the text content of the element matched by the provided selector. It will throw an error if the matched element is a document or doctype node because these nodes' textContent will be null. If no element is matched, then an error will be thrown.

Example

expect(extractTextContent('.hello-world')).toEqual('Hello World');

findElementBySelector()

Returns the element matched by the provided selector. If nothing is matched, null is returned.

Example

expect(findElementBySelector('.hello-world')).not.toBeNull();

fireEvent()

Dispatch the given eventType DOM event on the target element matched by the provided selector. The selector argument accepts 3 different types of value:

  • If it's a string, then it's treated as an HTML selector by which to find the target element to fire the event on. If no element is found for the provided selector, then an error will be thrown.
  • If it's an EventTarget such as Element or window, then the event is fired directly on it.
  • If it's a DebugElement, then its native element will be dispatched the event on.

Example

fireEvent('.hello-world', 'keyup', { key: 'Enter' });

getElementBySelector()

Returns the element matched by the provided selector. If nothing is matched, an error is thrown.

Example

expect(() => getElementBySelector('.hello-world')).not.toThrow();

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory