ja.guerrag[at}uniandes.edu.co | @duto_guerra
Slides:http://johnguerra.co/lectures/webDevelopment_fall2019/11_Testing/
Class page:http://johnguerra.co/classes/webDevelopment_fall2019/
We need:
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
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
./both/setup.tests.js
// setup file
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-15";
configure({ adapter: new Adapter() });
./imports/ui/Controls.tests.js
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.hasClass("Controls"));
chai.assert(controls.find("button").length, 4);
});
});