小编Ale*_*uni的帖子

Jest 未能测试导入 FontAwesomeIcon 的组件

我正在尝试使用 Jest 和 react-test-renderer 测试一个简单的功能性 react-native 组件。将 FontAwesomeIcon 组件导入我的组件后,我的测试失败并显示以下内容:

FAIL  src/BudgetLog/components/TransactionList/__tests__/TransactionList.test.js
? Test suite failed to run

Jest encountered an unexpected token

This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

Here's what you can do:
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" …
Run Code Online (Sandbox Code Playgroud)

react-native font-awesome-5

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

在 Rust 中使用正则表达式查询 MongoDB

我正在尝试实现存储桶模式作为上一个问题的解决方案。

在示例中,他们使用正则表达式的选择器发出更新:

db.history.updateOne({ "_id": /^7000000_/, "count": { $lt: 1000 } },
    { 
        "$push": { 
            "history": {
                "type": "buy",
                "ticker": "MDB",
                "qty": 25,
                "date": ISODate("2018-11-02T11:43:10")
            } },
        "$inc": { "count": 1 },
        "$setOnInsert": { "_id": "7000000_1541184190" }
    },
    { upsert: true })
Run Code Online (Sandbox Code Playgroud)

我试图在 Rust 中做同样的事情,但查询将我的正则表达式解释为字符串文字,而不是评估正则表达式。

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepetitionBucketUpdate {
    #[serde(with = "serde_regex")]
    id: Regex,
    device_id: Uuid,
    session_id: Uuid,
    set_id: Uuid,
    exercise: String,
    level: String,
    count: mongodb::bson::Bson,
}

impl From<JsonApiRepetition> for RepetitionBucketUpdate {
    fn …
Run Code Online (Sandbox Code Playgroud)

regex database mongodb rust

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

标签 统计

database ×1

font-awesome-5 ×1

mongodb ×1

react-native ×1

regex ×1

rust ×1