| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A set of convenient utilities to make Angular testing with Jasmine and Karma simpler.
npm i -S @lazycuh/angular-testing-kit
pnpm i -S @lazycuh/angular-testing-kit
yarn add @lazycuh/angular-testing-kit
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:
Will pass if no element with the provided class name exists in document.body.
assertThat('.hello-world').doesNotExist();Will pass if an element with the provided class name exists in document.body.
assertThat('.hello-world').exists();Will pass if an element with the provided class name has the provided inner HTML string.
assertThat('.hello-world').hasInnerHtml('<span>Hello World</span>');Will pass if an element with the provided class name has the provided string as its text content.
assertThat('.hello-world').hasTextContent('Hello World');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.
assertThat('.hello-world').hasTextContentMatching(/hello\s+world/i);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.
await delayBy(500);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.
expect(extractTextContent('.hello-world')).toEqual('Hello World');Returns the element matched by the provided selector. If nothing is matched, null is returned.
expect(findElementBySelector('.hello-world')).not.toBeNull();Dispatch the given eventType DOM event on the target element matched by the provided selector. The selector argument accepts 3 different types of value:
fireEvent('.hello-world', 'keyup', { key: 'Enter' });Returns the element matched by the provided selector. If nothing is matched, an error is thrown.
expect(() => getElementBySelector('.hello-world')).not.toThrow();| Back | FazBrowse Home | New Git URL |