2017-03-06 108 views
1

嘿,我已經在業力+茉莉+酶的配置一直工作,開始在我的項目的單元測試工作,然後在EXEC我的第一次測試,我得到這個錯誤未定義是不是構造茉莉花酶噶

TypeError: undefined is not a constructor (evaluating '(0, _jasmine.expect)(addLoan.length)') in src/app/modules/Login/LoginComponent.spec.js (line 80581) src/app/modules/Login/LoginComponent.spec.js:80581:29 [email protected]://localhost:9876/context.js:151:17

那麼這裏是我的測試代碼:

import React from 'react'; 
 
import { expect } from 'jasmine'; 
 
import { shallow } from 'enzyme'; 
 
import ServicerComponent from './LoginComponent'; 
 

 
function setup() { 
 
    const props = { 
 
     error: {}, 
 
     onClick:() => {}, 
 
     emailOnChange:() => {}, 
 
     passwordOnChange:() => {}, 
 
    }; 
 

 
    return shallow(<ServicerComponent{...props} />); 
 
} 
 

 
describe('<ServicerComponent />',() => { 
 
    const displayNames = { 
 
     login: 'login', 
 
    }; 
 
    let wrapper; 
 

 
    beforeEach(() => { 
 
     wrapper = setup(); 
 
    }); 
 

 
    it('should have a Login button',() => { 
 
     const addLoan = wrapper.find({ name: displayNames.login }); 
 

 
     expect(addLoan.length).toBe(1); 
 
    }); 
 
});

也是我使用: 茉莉:2.5.3 酶:2.7.1

回答

0

您需要創建

beforeEach(() => { 
     wrapper = new setup(); 
    }); 
+0

對不起,但沒有解決方法:c –

0

我已經找到了問題的答案之類的設置情況,我只是刪除茉莉花進口商並在.eslintrc.json中加入一個全局變量expect等於true