Coder Social home page Coder Social logo

david-desmaisons / componentfixture Goto Github PK

View Code? Open in Web Editor NEW
51.0 3.0 6.0 18.37 MB

🛠️Interactive sandox playground for vue components

Home Page: https://david-desmaisons.github.io/ComponentFixture/

License: MIT License

JavaScript 49.42% Vue 50.26% HTML 0.32%
vuejs component fixture-test sandbox testing-tools playground

componentfixture's Introduction

Component Fixture

CircleCI Coverage codebeat badge GitHub open issues Npm version MIT License

Demo

https://david-desmaisons.github.io/ComponentFixture/

Description

Interactive test fixture for vue component.

Component is designed to receive any component you want to test as a default slot

<sandbox>

  <!-- Use the default slot to create the component under test -->
  <component-under-test/>

</sandbox>

Component-fixture will automatically:

  • Mirror all the props of the tested component
  • Bind this data to the component under-test
  • Display all the props in a form so that it is possible to edit them

Features:

  • Respect props type and use custom input for each type
  • Provide input for objects and function
  • Create v-model binding if needed
  • Support of two-way data binding using the .sync modifier pattern
  • Custom props validation when available
  • Support component with slots
  • Display of all events emitted by the component
  • Display of component data and computed information
  • Exposition of component method as buttons that can be called with display of the produced result
  • Compatible with hot-reload: automatic update on changes happening on the tested component

Example using vue-slider-component:

demo

Uses cases

Why would you need such a component?

ComponentFixture is intended to be used only in a test/dev context with two main applications.

Discovering third party component

  • Explore Interactively a component you are willing to use in your application.
  • Understand by example what the props role.
  • Quickly identify bugs and limitation on the component.

Testing a component you creates

  • Create an example usage of your component that will update automatically
  • Interact with the component while you create it.
  • Easily identify bugs

Next steps

  • Provide a way to default component props
  • Monkey testing: use randomly generated updates on component props.

This will be provided on next major version.

Example usage

<sandbox :defaults="{value: 23}">

  <!-- Use the default slot to for the component under test -->
  <component-under-test></component-under-test>

</sandbox>
import { Sandbox } from 'component-fixture'
import "component-fixture/dist/ComponentFixture.css"
import { componentUnderTest } from 'componentUnderTest'

export default {
  components: {
    componentUnderTest,
    Sandbox
  }
}

API

slots

  • default Slot for the component under test

props

  • defaults Object (optional)

    Value: {[propName]: defaultValue}

    Object sets to default the component under-test props. For example if you want to default the props value with 46, use: :defaults="{value: 46}"

  • possibleValues Object (optional)

    Value: {[propName]: [...values]}

    Object used to predefined the possible values for a given props. The values defined by possibleValues will be used to create a select from the provided values for the given props. For example if you want to limit the props value to 1,2, 3 or 4, use: :possibleValues="{value: [1,2,3,4]}"

  • componentHeight String (optional)

    Style to be applied to the component under-test height. Default to null.

  • componentWidth String (optional)

    Style to be applied to the component under-test width. Default to null.

  • useStore Boolean (default: false)

    If true and vuex is being used, a store module is automatically created and its state is bound to component props.

Installation

npm install ComponentFixture

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Run your unit tests

npm run test:unit

Update the API section of README.md with generated documentation

npm run doc:build

Run style guide dev server

npm run styleguide

Generate a static HTML style guide

npm run styleguide:build

componentfixture's People

Contributors

david-desmaisons avatar rbqdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

componentfixture's Issues

Improve layout

  • Improve item order
  • feedback on v-model updates
  • Check colors
  • improve bool symbol
  • Add property name on validation error
  • Layout for multi-type props
  • Dirty feedback

Too agressive styles

Hi.
this line breaks down component style


Also dist css file include bootstrap which also overrite components styles and components look different
For such project type better use only scoped styled componets

I very like this project but I can use it due these issues

Add list of possible values for given props

Possible values will appear as drop-down in the editor.
Create version 2 (breaking changes)?

Use these values for monkey atack

  • Add validation check?
  • Check hot-reload
  • Check display for object

Add Monkey atack

  • Check changing type of object
  • Add binding to attack parameters
  • Add to default button
  • Log monkey attack error on monkey attack component
  • Create-accept seed value
  • Stop monkey attack on destroy
  • Add call the component method
  • Add attack summary with seed
  • Add replay attack button
  • Add feedback whe attack ends
  • Add mouse element optional
  • Treat vue warn as error=> console.error
  • Stop on first error
  • Check bug when closing editors
  • Check component reset with key
  • Reset attack list

Component attributes

Hi!
Is it possible to prefix the component attributes to a fixed value?

example

export default {
  name: 'app',
  components: {
    ComponentFixture,
    Editor,
    component
  },
  data: () => ({
    value: 'my value'
  })
}

and then

<component-fixture class="content">
      
  <component v-model="value">
  </component>

  <Editor slot="control" slot-scope="scope" v-bind="scope"/>

</component-fixture>

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.