菜鸟问题。我有下面的代码,我想为此创建一个测试用例。
class APIInstanceView extends React.Component {
constructor(props) {
super(props);
this.state = { instanceData: [],
apiData: [],
mode: "loading",
};
}
componentDidMount() {
let insturl = DJANGOURL_rest_apis_instance_api.replace('__API__',this.props.api)
let apiurl = DJANGOURL_rest_apis_one.replace('__API__',this.props.api)
$.when(
$.get(apiurl),
$.get(insturl)
).then(function (api, instance) {
}.bind(this),
function(){
// ERROR
}.bind(this))
}
使用以下代码运行jest时
describe('APIInstanceView', () => {
it('change api instance view based on state', () => {
// Render a checkbox with label in the document
const menu = TestUtils.renderIntoDocument(
<APIInstanceView />
);
});
});
我收到一条ReferenceError:未定义DJANGOURL_rest_apis_instance_api。
我应该如何以及在哪里定义DJANGOURL_rest_apis_instance_api?
由于
答案 0 :(得分:0)
尝试在renderIntoDocument之前添加<button class="addFormat" data-bind="visible: $index() == $parent.ArrayLength() -1">+</button></p></td>
。