0.1.0 • Published 6 years ago

weltest v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago