https://github.com/ujjwalguptaofficial/mahal-test-utils
Official library for testing mahal application
https://github.com/ujjwalguptaofficial/mahal-test-utils
javascript mahal-framework testing-library typescript
Last synced: 8 months ago
JSON representation
Official library for testing mahal application
- Host: GitHub
- URL: https://github.com/ujjwalguptaofficial/mahal-test-utils
- Owner: ujjwalguptaofficial
- License: mit
- Created: 2020-09-02T02:04:36.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-22T07:43:38.000Z (over 2 years ago)
- Last Synced: 2025-03-08T04:46:10.210Z (9 months ago)
- Topics: javascript, mahal-framework, testing-library, typescript
- Language: TypeScript
- Homepage:
- Size: 569 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/js/@mahaljs%2Ftest-utils)
[](https://github.com/ujjwalguptaofficial/mahal-test-utils/actions/workflows/ci.yml)
[](https://badge.fury.io/gh/ujjwalguptaofficial%2Fmahal-test-utils)
# mahal-test-utils
Official library for testing [mahal](https://github.com/ujjwalguptaofficial/mahal) application
# Installation
```
npm i @mahaljs/test-utils
```
# Docs
## initiate
component can be initiated by calling `initiate` method
```
import Counter from "../src/components/counter";
import { initiate } from "mahal-test-utils";
const component = await initiate(Counter);
```
## mount
component can be mounted by calling `mount` method
```
import Counter from "../src/components/counter";
import { mount } from "mahal-test-utils";
const component = await mount(Counter);
```
## setInputValue
setInputValue can be used to set the value of an input element. It takes two arguments -
1. input element
2. value to set
```
import Counter from "../src/components/counter";
import { mount } from "mahal-test-utils";
const component = await mount(Counter);
const inputEl = component.find('input');
setInputValue(inputEl, 'hello')
```
## Pass app instance
Let's say you want to use your app instance because it contains different global value e.g - formatters, global variables etc.
In order to do that you just need to change the context of the available testing methods.
Let's see an example of `mount` -
```
import Counter from "../src/components/counter";
import { mount } from "mahal-test-utils";
import { app } from "../src/index.ts";
const component = await mount.call(app, Counter);
```