我正在尝试使用 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) 在示例中,他们使用正则表达式的选择器发出更新:
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)