Unit Test React Components in Meteor

it(“should show how easy it is to test!”, function() {
  // render into DOM
  renderWithProps({name: 'Joe'});
  expect(component.props.name).toBe('Joe');
  expect(component.getGreeting()).toBe('Hello Joe');
  component.toggleHidden();
  expect(component.state.isHidden).toBe(true);
  expect($el.find('.name').text()).toBe('First Name:');
});
meteor create test-example
cd test-example
meteor add sanjo:jasmine velocity:html-reporter react
rm test-example.html test-example.css test-example.js
touch EvenOrOdd.jsx main.html
<head>
  <title>Meteor Test Tutorial</title>
</head><body>
  <div id=”app”></div>
</body>
mkdir -p tests/jasmine/client/unit
touch tests/jasmine/client/unit/spec_helper.js
touch tests/jasmine/client/unit/EvenOrOdd_spec.js
tests/jasmine/client/unit/spec_helper.js

All About MeteorJS

Posts covering Meteor.JS

Adam Brodzinski

Written by

Software Engineer

All About MeteorJS

Posts covering Meteor.JS