Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nyc does not work in ReactNative .js which has <View> #1317

Closed
OnTheWay111 opened this issue May 20, 2020 · 1 comment
Closed

nyc does not work in ReactNative .js which has <View> #1317

OnTheWay111 opened this issue May 20, 2020 · 1 comment

Comments

@OnTheWay111
Copy link

OnTheWay111 commented May 20, 2020

problem .js

Ex: https://github.com/OnTheWay111/AwesomeProject/blob/master/coverage_middleware/jss/App.js
used nyc version: 11、12、13、14、15
use cmd:

nyc instrument js ../js

Valid code: like this

var App = React.createClass({
    render: function () {
        return (
            1
        )
    }
});

does not work code

    render: function () {
        return (
            <View style={{ flex: 1, justifyContent: "center", alignItems: "center", flexDirection: 'column' }}>
                <Text>你好吃了吗11111?</Text>
            </View>
        )
    }
});

please help me

@OnTheWay111
Copy link
Author

it is my fault; 利用这个方法解决了:
nyc插桩ReactNative的js文件失败的问题解决了,主要是nyc的版本问题,降版本到14.1.1可以了。

注意:package.json直接指定nyc版本和全局nyc版本的区别,如果是直接运行nyc instrument,用的是全局版本
问题解决了,解决方法如下,特别感谢 @zsx10110
我之前使用的降版本方式是package.json中修改版本号,然后npm install , 然后nyc instrument插桩,注意:此时使用的nyc是全局nyc,并不是node_modules中的nyc,所以用的还是全局版本的nyc,导致降版本无效;
感谢@zsx10110 大大,成功帮我解决了,使用如下命令,强制降版本全局nyc:

npm install -g nyc@14.1.1 --registry https://registry.npm.taobao.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant