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)