很简单,我想用Jest运行一个测试.
我放it.only或describe.only但它仍然运行了很多测试.我认为自从我上一次提交以来它运行了所有测试,但它不应该only明确设置标志的这种行为,对吧?
导致此行为的原因以及如何运行单个测试?
我有 3 个文件:authors.py,posts.py和schema.py.
帖子有一个作者,查询构建在架构文件中。
我试图Author从内部Post解析而不在 中声明解析器函数Post,因为Author已经声明了一个解析器函数。以下代码有效,但我必须resolve_author从Post类型内部进行引用,这似乎不对。我认为 Graphene 应该parent直接将参数传递给Author,不是吗?
如果我没有author在Post类型中设置解析器,它只会返回null.
模式.py
import graphene
from graphql_api import posts, authors
class Query(posts.Query, authors.Query):
pass
schema = graphene.Schema(query=Query)
Run Code Online (Sandbox Code Playgroud)
作者.py
from graphene import ObjectType, String, Field
class Author(ObjectType):
id = ID()
name = String()
class Query(ObjectType):
author = Field(Author)
def resolve_author(parent, info):
return {
'id': '123',
'name': …Run Code Online (Sandbox Code Playgroud) 我用Chart.js创建了一个圆环图,我希望它的两端都有圆角.我希望它是这样的:
但我喜欢这样,有锋利的边缘:
我找到的最好的答案是:如何在Chart.js条形图上放置圆角,但它是用于条形图,我不知道如何为甜甜圈调整它.
这是我的代码:
HTML
<div class="modal-div-canvas js-chart">
<div class="chart-canvas">
<canvas id="openedCanvas" width="1" height="1"></canvas>
<div class="chart-background"></div>
<span class="chart-unique-value">
<span class="js-count">
85
</span>
<span class="cuv-percent">%</span>
</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
var deliveredData = {
labels: [
"Value"
],
datasets: [
{
data: [85, 15)],
backgroundColor: [
"#3ec556",
"rgba(0,0,0,0)"
],
hoverBackgroundColor: [
"#3ec556",
"rgba(0,0,0,0)"
],
borderWidth: [
0, 0
]
}]
};
var deliveredOpt = {
cutoutPercentage: 88,
animation: {
animationRotate: true,
duration: 2000
},
legend: {
display: false
},
tooltips: …Run Code Online (Sandbox Code Playgroud) 我正在使用Jest,并且想从另一个模块中模拟一些功能(我们称之为dependency)。
我能够进行dependency 全局模拟,将其放入__mocks__文件__tests__夹中的文件夹中。
Unfortunately, I need the actual dependecy for all the other tests. So, how can I specify that I want to require the mocked dependecy only when required in my file1.js, but not in all other files?
PS: I could create a __mocks__ folder inside my file1.js folder, but this file is in the root, so when dependency is required by any file it will be picked …