【发布时间】:2018-06-01 04:49:41
【问题描述】:
这是我的js文件
import React, { Component } from 'react';
export default class ProjectStore extends Component {
static lodingCount = 0;
constructor(props) {
super(props);
}
static setLodingCount(countValue){
ProjectStore.lodingCount = countValue;
}
static getLodingCount(){
return ProjectStore.lodingCount;
}
}
我写了一个测试用例,如下所示:
import React from 'react';
import {shallow} from 'enzyme';
import ProjectStore from '../projectStore.js';
describe('<ProjectStore />', () => {
it('should return loading count', () => {
const ProjectStore = shallow(<ProjectStore />);
ProjectStore.setLodingCount(2);
expect(ProjectStore.lodingCount).toEqual(2);
});
});
但是当我执行npm test 时它返回了:
ReferenceError: ProjectStore is not defined
我在这里做错了什么?
【问题讨论】:
标签: javascript reactjs jestjs enzyme