@mahaljs/test-utils
v1.9.0
Published
Official test plugin for mahal framework.
Downloads
27
Maintainers
Readme
mahal-test-utils
Official library for testing 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 -
- input element
- 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);