我有一个组件,它使用Animated来自react native 的组件.我开始编写一个测试用例来模拟onPress一个组件,它调用一个包含Animated.timing在其中的函数setState.
运行jest正常,但测试永远不会停止运行,我之前写过的一个不相关的测试用例现在似乎永远不会通过(之前通过).
运行jest --watch,我收到此错误:
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down.
at Function.bezier (node_modules/react-native/Libraries/Animated/src/Easing.js:113:21)
at ease (node_modules/react-native/Libraries/Animated/src/Easing.js:34:24)
at TimingAnimation._easing (node_modules/react-native/Libraries/Animated/src/Easing.js:133:18)
at TimingAnimation.onUpdate (node_modules/react-native/Libraries/Animated/src/animations/TimingAnimation.js:107:45)
RUNS src/__tests__/SlideDownMenu.test.js
/home/nrion/Desktop/mobile-ui/PriceInsight_app/node_modules/react-native/Libraries/Animated/src/Easing.js:114
return _bezier(x1, y1, x2, y2);
^
TypeError: _bezier is not a function
at Function.bezier (/home/nrion/Desktop/mobile-ui/PriceInsight_app/node_modules/react-native/Libraries/Animated/src/Easing.js:224:12)
at ease (/home/nrion/Desktop/mobile-ui/PriceInsight_app/node_modules/react-native/Libraries/Animated/src/Easing.js:94:21)
at TimingAnimation._easing (/home/nrion/Desktop/mobile-ui/PriceInsight_app/node_modules/react-native/Libraries/Animated/src/Easing.js:255:16)
at TimingAnimation.onUpdate (/home/nrion/Desktop/mobile-ui/PriceInsight_app/node_modules/react-native/Libraries/Animated/src/animations/TimingAnimation.js:138:14)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at …Run Code Online (Sandbox Code Playgroud) 好吧,这很奇怪。我的终端(带有 zsh 的 iterm2)使用control + m或control + shift + cnow 而不是仅退出命令control + c。
关于为什么会发生这种情况的任何想法?谢谢!
如标题所述,eslint是否有可能在所有规则上显示警告而不是错误?如果该信息相关,我正在使用Standard JS。
谢谢!
伙计们!我的 MongoDB 中有这些数据:
{
"_id" : ObjectId("5aa35c78e84868839683c4ca"),
"dateTransacted" : ISODate("2018-03-10T04:18:00.074Z"),
"taskerFee" : 1500,
"customerFee" : 4000,
"transactionFee" : 50,
"mnmltaskrProfit" : 30
},
{
"_id" : ObjectId("5aa3ac08e84868839683c4cb"),
"dateTransacted" : ISODate("2018-03-10T09:57:28.637Z"),
"taskerFee" : 300,
"customerFee" : 1500,
"transactionFee" : 50,
"mnmltaskrProfit" : 60
}
Run Code Online (Sandbox Code Playgroud)
我想按月和年查询它,以便它返回类似以下内容的内容:
{
'month': 'September',
'year': 2018,
'transactions': [
{
"_id" : ObjectId("5aa3ac08e84868839683c4cb"),
"dateTransacted" : ISODate("2018-03-10T09:57:28.637Z"),
"taskerFee" : 300,
"customerFee" : 1500,
"transactionFee" : 50,
"mnmltaskrProfit" : 60
},
{
"_id" : ObjectId("5aa3ac08e84868839683c4cb"),
"dateTransacted" : ISODate("2018-03-10T09:57:28.637Z"),
"taskerFee" : …Run Code Online (Sandbox Code Playgroud) 这是实际工作的代码在中间对齐文本:
<div class="container section-content">
<div class="row" style="border-radius: 4px; border: solid 1px #979797;">
<div class="col-md-3 align-self-center" style="background-color: #4a90e2">
Align
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我如何实现这一目标?
编辑:不是如何使 Bootstrap 列的高度相同? 这是垂直对齐的问题
我的里面有以下代码async componentdidmount:
async componentDidMount() {
try {
let responseText = await API.Licensing()
this.setState({ html: responseText })
} catch (e) {
this.setState({ html: 'Error Fetching Licensing Info' })
}
}
Run Code Online (Sandbox Code Playgroud)
我对如何在这里测试 setstate 感到困惑,因为互联网上的大多数示例都使用 Promise then/catch,而这个示例使用 try/catch async/await。
测试会是什么样子?
reactjs ×3
enzyme ×2
jestjs ×2
react-native ×2
bootstrap-4 ×1
css ×1
eslint ×1
eslintrc ×1
html ×1
iterm2 ×1
javascript ×1
macos ×1
macos-mojave ×1
mongodb ×1
oh-my-zsh ×1
sorting ×1
standardjs ×1
zsh ×1