John Alexis Guerra Gómez


Class page:http://johnguerra.co/classes/webDevelopment_fall2019/

Readings discussion

  • questions?


Types of Testing

  • Unit test
  • Integration test
  • Acceptance test (end to end test)
  • Load test

Testing React

We need:

Install dependencies

meteor npm install --save-dev enzyme
meteor npm install --save-dev react-test-renderer@15
meteor npm install --save-dev enzyme enzyme-adapter-react-15

Add test files

Create a ./both/setup.tests.js that setups the adapter for enzyme

Then create a ./imports/ui/Controls.tests.js that test the Controls React component


// setup file
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-15";

configure({ adapter: new Adapter() });


import React from "react";
import { shallow } from "enzyme";
import { chai } from "meteor/practicalmeteor:chai";
import Controls from "./Controls.jsx";

describe("Controls", () => {
  it("should render", () => {

    const controls = shallow(<Controls onMove={this.onMove}></Controls>);
    chai.assert(controls.find("button").length, 4);