1
我第一次使用jest與React,這次我將它與React Native項目一起使用。並在下面的代碼完美工作。Jest失敗,外部npm包
import React, { Component } from 'react';
import {
Text,
View,
} from 'react-native';
export default class Login extends Component {
render() {
return (
<View>
<Text>Login Page</Text>
</View>
)
}
}
但是在我的組件庫中添加了一個按鈕後,jest未通過測試。
import React, { Component } from 'react';
import {
Text,
View,
} from 'react-native';
import { Button } from 'tc-components';
export default class Login extends Component {
render() {
return (
<View>
<Text>Login Page</Text>
<View>
<Button onPress={this.loginHandler.bind(this)}>Log in</Button>
</View>
</View>
)
}
}
錯誤信息
- SyntaxError: Unexpected reserved word
at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:306:10)
at Object.<anonymous> (app/scenes/Activity.js:2:17)
at Object.<anonymous> (__tests__/Activity-test.js:3:15)
1 test suite failed, 0 tests passed (0 total in 1 test suite, run time 1.261s)