Comments (3)
We use vitest ourselves, checkout any of our tests for examples on how to do this: https://github.com/formkit/formkit/tree/master/packages/vue/__tests__/inputs
from formkit.
@justin-schroeder Thanks for the response, I have looked into the tests as an example and I don't get it get it working.
I used the import { FormKit } from '@formkit/vue';
this imports the definition:
The root FormKit component.
@public
export declare const FormKit: DefineComponent< { ..... etc
In the formkit test the formkit definition is:
The root FormKit component. Use it to craft all inputs and structure of your forms. For example:
vue
<FormKit
type="text"
label="Name"
help="Please enter your name"
validation="required|length:2"
/>
@public
export const formkitComponent = defineComponent(setup as any, {
props: runtimeProps as any,
inheritAttrs: false,
}) as FormKitComponent
....
In my vitest I want to create a wrapper like:
wrapper = mount(Pincode, {
global: {
components: {
PrevNextButtons: PrevNextButtons,
FormKit,
},
plugins: [
createTestingPinia({
createSpy: vitest.fn,
}),
],
},
});
console.log(wrapper.html());
I cant defineProps or assign props to Formkit
Any Ideas?
from formkit.
You need to register the FormKit plugin in your test. For example:
import { plugin, defaultConfig } from '@formkit/vue'
describe('some formkit inputs', () => {
it('can render a text input', () => {
const wrapper = mount(FormKit, {
props: {
type: 'text',
value: 133,
},
{
global: {
plugins: [[plugin, defaultConfig]],
}
},
})
expect(wrapper.find('input').exists()).toBe(true)
})
})
Of course you could render at template component with pinia or other plugins too.
from formkit.
Related Issues (20)
- Missing types for slots in the Autocomplete input HOT 5
- Dynamic lists should make all child names and IDs unique by default. HOT 1
- created not emit HOT 2
- datepicker events don't include event object HOT 3
- Dropdown Input with Dynamic Options and `#option` Slot HOT 3
- Checkbox: Invalid markup (div within label) HOT 1
- Custom submit button won't get disabled during request HOT 1
- Add new core event for any mutation to children array. HOT 4
- Warning when using multiStep plugin with schema
- Taglist and Autocomplete options prop not reacting to reactive data HOT 4
- Autocomplete: accessibility issues HOT 9
- Accessibility Improvements
- Autocomplete: faulty behaviour with many items HOT 1
- Font descenders cut off HOT 2
- Invalid TypeScript types for custom element slots HOT 2
- Name attribute not set on datepicker input HOT 2
- Serialize sections-schema for `schemaMemoKey` with custom replacer for inline functions. HOT 3
- Double clicking slider input leads to selection of tooltip
- Slider input does not react to changes in max property HOT 4
- Slider handle won't update after binded value updates HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formkit.