2017-08-11 28 views
1

我試圖用Jest測試一個基本的反應組件,但是當我嘗試導入組件時它會中斷。編輯:注意到它不會拋出這個錯誤,如果我加載一個更簡單的組件。我試圖加載的基本上是相同的,但有一個async實例方法。也許這就是開玩笑吧?Jest拋出錯誤試圖導入組件時出現意外的標記功能

test.js

import React from 'react'; 
import {shallow} from 'enzyme'; 
import Component from '../components/component'; 


describe('Component',() => { 

    it('renders the player component',() => { 

     expect(true).toBe(true) 

    }); 


}); 

.babelrc

{ 
    "presets": ["es2015", "react"] 
} 

的package.json笑話配置:

"jest": { 

    "setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js", 

    "moduleFileExtensions": [ 
     "ts", 
     "tsx", 
     "js", 
     "json", 
     "jsx" 
    ], 

    "unmockedModulePathPatterns": [ 
     "<rootDir>/node_modules/react", 
     "<rootDir>/node_modules/react-dom", 
     "<rootDir>/node_modules/react-addons-test-utils" 
    ] 
    } 
+0

你用摩卡? – Roman

+0

@Roman nope只是想用Jest/Enzyme –

+0

對不起。不知道Jest是自己的測試賽跑者.. – Roman

回答

相關問題