小编Ric*_*ard的帖子

意外的标记“<”笑话和带有打字稿测试文件的testing-library/react-native

运行以下测试文件时出现以下错误:

// TestComp.test.tsx
import React from "react";
import { TextInput, View } from "react-native";

import { render, fireEvent } from "@testing-library/react-native";

const TestComp = () => {
  return (
    <View>
      <TextInput testID="test-input" onChangeText={(txt) => console.log(txt)}></TextInput>
    </View>
  );
};

describe("Testcomp", () => {
  afterEach(() => {
    jest.clearAllMocks();
  });

  test("test me", async () => {
    const { getByTestId } = render(<TestComp />);
    const testInput = getByTestId("test-input");
    fireEvent.changeText(testInput, "hello");
  });
});
Run Code Online (Sandbox Code Playgroud)

运行时出错yarn jest

    Details:

    /mnt/ubuntu/home/richardwu/code/topspin/src/components/TestComp.test.tsx:46
        return (<react_native_1.View>
                ^

    SyntaxError: Unexpected token …
Run Code Online (Sandbox Code Playgroud)

jestjs babeljs

7
推荐指数
1
解决办法
4407
查看次数

无法连接到 TCP 端口:尝试在 WSL2 中的 Android 模拟器上打开 Expo 应用程序时连接被拒绝

我一直在关注本指南https://medium.com/@pellea/using-adb-with-wsl2-7aebbb070a47到目前为止,WSL2 可以通过 Android Studios 看到在 Windows 上运行的模拟器-> AVD 管理器。例如,在 Windows 和 WSL2 上,adb devices正确显示:

List of devices attached
emulator-5554   device
Run Code Online (Sandbox Code Playgroud)

但是,当我转到我的 expo 应用程序并尝试启动 Android 模拟器时,我收到以下错误消息

Couldn't start project on Android: could not connect to TCP port 5554: Connection refused
Run Code Online (Sandbox Code Playgroud)

这是在我尝试以下操作之后:

  1. ADB_SERVER_SOCKET=tcp:<MY IP>:5037在我的 WSL2 配置文件中导出
  2. 通过(来自上面的链接)从我的 Windows 防火墙取消阻止 WSL2 vEthernet 连接
Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)"
Run Code Online (Sandbox Code Playgroud)
  1. 我已经将 5554 从 Windows 转发到 WSL2,以及 5037(从 0.0.0.0 到 127.0.0.1):
$WSL_CLIENT = bash.exe -c "ip addr show eth0 | …
Run Code Online (Sandbox Code Playgroud)

adb windows-subsystem-for-linux expo

5
推荐指数
2
解决办法
1768
查看次数

react-hook-form submit 没有从 jest 测试中获取 changeText

我有以下几点react-native-form

const { register, handleSubmit, setValue, errors } = useForm();

const onSubmit = (data) => {
  console.log(data);
  return firebase
    .auth()
    .signInWithEmailAndPassword(data.email, data.password)
    .then((info) => {
      console.log(info.additionalUserInfo.profile);
    })
    .catch((err) => {
      console.error(err);
    });
};

  <View>
    <TextInput
      placeholder="Email"
      testID="email-input"
      onChangeText={(t) => setValue("email", t)}
      style={styles.loginTextInput}
    ></TextInput>
    <TextInput
      secureTextEntry={true}
      testID="password-input"
      placeholder="Password (min. 8 characters)"
      onChangeText={(t) => setValue("password", t)}
      style={styles.loginTextInput}
    ></TextInput>
    <TouchableOpacity
      onPress={handleSubmit(onSubmit)}
      testID={"login-email-button"}
      style={[styles.loginButton, styles.loginEmailButton]}
    >
      <Text style={styles.buttonText}>Login with Email</Text>
    </TouchableOpacity>
  </View>
Run Code Online (Sandbox Code Playgroud)

我正在测试提交和调用firebase.auth().signInWithEmailAndPasswordusingjest在以下测试中:

test("submit works", async () => …
Run Code Online (Sandbox Code Playgroud)

jestjs react-hook-form

5
推荐指数
1
解决办法
209
查看次数

物化选择输入显示两个插入符号

我刚刚将Materialise集成到我的Rails项目中gem 'materialize-sass'.出于某种原因,选择输入显示两个插入符号而不是1.

在此输入图像描述

select输入的代码基本上是他们网站上示例的一个分支.

<div class="input-field">
    <select name="tutor_profile[dob_month]" id="tutor_profile_dob_month">
        <option value="" disabled selected>Choose your month</option>
        <option value="1">January</option>
        <option value="2">February</option>
        <option value="3">March</option>
        <option value="4">April</option>
        <option value="5">May</option>
        <option value="6">June</option>
        <option value="7">July</option>
        <option value="8">August</option>
        <option value="9">September</option>
        <option value="10">October</option>
        <option value="11">November</option>
        <option value="12">December</option>
    </select>
    <label>Birthday</label>
</div>
Run Code Online (Sandbox Code Playgroud)

我试过调整开发人员控制台中的选择按钮的CSS样式,但没有成功.选择输入中的任何元素都没有其他样式.

我正在使用的其他CSS框架是bootstrap,bootstrap-tagsinput,twitter-typeahead和jquery-ui.我想知道是否有人有类似的经历.

ruby-on-rails materialize

4
推荐指数
1
解决办法
1697
查看次数

使用 != 和 not-in 进行查询会在 firestore 中使用 Query.where 引发错误

我尝试使用!=not-in作为参数,如下Query.where所述:

    db.collection("users")
      .where(firebase.firestore.FieldPath.documentId(), "!=", curUser.uid)
      .get()
      .then((snapshot) => {
         ...
      });
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

为函数 Query.where() 的第二个参数提供的值“!=”无效。可接受的值:<、<=、==、>=、>、array-contains、in、array-contains-any

我什至在普通的非文档 ID 字段上尝试过此操作,但它给出了相同的错误。

我使用的是节点包firebase版本 7.9.0。

javascript firebase google-cloud-firestore

3
推荐指数
1
解决办法
777
查看次数

在Fullcalendar Rails中拖动日历事件的速度很慢

我已经在我的Rails项目中导入了fullcalendar gem 'fullcalendar-rails', '~> 2.3.1.0'.

每当我在我的日历上拖动事件时,都存在显着的"延迟",即事件UI元素在周围徘徊.http://fullcalendar.io上的版本明显更好.

有没有人有同样的问题和/或你如何解决它?

编辑:

我忽略了包含任何实现代码,因为即使使用vanilla实现也无法使日历工作,所以我认为这是fullcalendar-rails的一个问题.我在下面包含了我的解决方案(碰巧是designmodo的flat-ui样式表的错误).

calendar jquery-ui ruby-on-rails fullcalendar

1
推荐指数
1
解决办法
494
查看次数

如何为 Devise Mailer 电子邮件设置自定义密件抄送/收件人字段?

我想在通过 Devise 发送的所有电子邮件的 to/bcc 标头中包含我用户的名字和姓氏。

我看了这个https://github.com/plataformatec/devise/blob/master/lib/devise/mailers/helpers.rb#L28

似乎 Devise 也像@email在模板中一样分配了 to 字段。我将如何覆盖标头,以便使用 to/bcc 标头发送电子邮件"FirstName LastName <email@example.com>"

ruby-on-rails devise

1
推荐指数
1
解决办法
892
查看次数

查找具有特定键值对的JS对象/哈希

假设我有一个JS对象,其中包含多个具有相同属性的对象.

编辑:我将外括号修改为方括号以反映实际对象是什么.接受的答案在评论中.

var object = [
   {
      id: 1,
      foo: 'bar'
   },
   {
      id: 2,
      foo: 'bar2'
   },
   {
      id: 3,
      foo: 'bar3'
   },
   {
      id: 4,
      foo: 'bar4'
   }
];
Run Code Online (Sandbox Code Playgroud)

我如何获得具有特定id的对象,例如id == 1类似于Rails方法的东西ActiveRecord::Relation.where(id: 1)

javascript jquery ruby-on-rails

0
推荐指数
1
解决办法
1692
查看次数