Skip to content

Bloomca/weltest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weltest

Build Status

Library to test welgo library code.

API

Shallow rendering:

const { createElement } = require('welgo');
const htm = require('htm');
const { shallow } = require('weltest');

const html = htm.bind(createElement);

test('<MyComponent /> renders three <Foo /> components', () => {
  const wrapper = shallow(html`<${MyComponent} />`);
  expect(wrapper.find(Foo)).to.have.lengthOf(3);
});

it('<MyComponent /> renders an `.icon-star`', () => {
  const wrapper = shallow(html`<${MyComponent} />`);
  expect(wrapper.find('.icon-star')).to.have.lengthOf(1);
});

Instead of using shallow, you can use mount method:

const { mount } = require('weltest');

The idea of shallow/full-rendering is taken from enzyme.

Right now wrapper offers only one method – find. If you pass a selector (for querySelector), it will return a list of DOM nodes. If you pass an actual component, it will return an array of wrappers, on which you can find again.

Run

If you want to run tests in this repository, you'll need Node v10+.

npm i
npm t

License

MIT

About

Library for testing Welgo components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published