我目前正在测试我的一个React组件,如下所示:
it('renders correctly', () => {
const tree = renderer.create(<Scene {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
我的组件Scene
导入setting.json
文件.我在我的本地实例上有该文件,但我没有在我的CI实例上推送它.因此,当它尝试导入它时,找不到该文件.
有没有办法在我的测试中模拟这个文件?
有没有办法忽略 Jest 的错误?
我在导入包时收到错误,并且想忽略该错误,以便可以测试其余的代码。
我有一个React-native应用程序,我需要通过websockets与IoT(AWS)连接.我目前使用包react-native-paho-mqtt连接我的应用程序.这是我的代码:
function getClient(onConnect, onConnectionFailed, onConnectionLost,
onMessageArrived) {
logger.trace('getClient()');
const clientID = uuidV4();
// Create a client instance
const client = new Paho.MQTT.Client(signedUrl, clientID); // eslint-disable-line no-undef
// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
// connect the client
client.connect({
keepAliveInterval: 15,
onSuccess: onConnect,
onFailure: onConnectionFailed,
});
return client;
}
Run Code Online (Sandbox Code Playgroud)
在我的主连接后5分钟,当我尝试连接其他客户端时出现错误.我收到这个错误:AMQJS0007E Socket error:{0}.
.我没有关于错误的更多信息.
有谁知道发生了什么或如何解决这个问题?