【发布时间】:2017-02-13 07:16:21
【问题描述】:
我正在通过 site 学习 TDD 和 React,但不明白作者是如何获得 describe 和 it 的,这些通常不是来自 Jasmine 吗?我在作者的 github 上的 node_modules 中没有看到这个包,他的 tests.js 也没有导入任何看起来像 describe 或 it 的东西。这两种方法从何而来?
import React from 'react';
import { expect } from 'chai';
import { shallow, mount, render } from 'enzyme';
describe('Test suite for User component', () => {
it('UserComponent should exist', () => {
let wrapper = shallow(<User />)
expect(wrapper).to.exist;
});
});
【问题讨论】:
-
他们来自
mocha。作者已经将它添加到 package.json 中以使用 mocha 运行测试。检查这个github.com/r31gN/tdd-react-enzyme-article/blob/master/…。 -
我注意到他也使用了#childAt,但他没有从酶中导入,这怎么可能?
-
我认为你弄错了。这是一个包装对象的方法。
标签: javascript reactjs tdd chai enzyme