我开始围绕应用程序中的 prisma(v3.6.0) 使用情况编写测试。
为此,我遵循了官方 prisma 页面使用 prisma 进行单元测试,并且我正在使用jest-mock-extended.
我的问题是,在使用模拟的 prisma 函数时出现打字稿错误:
describe('User routes', () => {
it('should respond success with array of users', async () => {
prismaMock.user.findMany.mockResolvedValue([]); // <- here is the error
}
}
Run Code Online (Sandbox Code Playgroud)
Type of property 'AND' circularly references itself in mapped type
Run Code Online (Sandbox Code Playgroud)
github Testing with prisma上有一些关于这个问题的讨论。我从这次讨论中得到了 3 个选择:
"skipLibCheck": true到 tsconfig.json。这破坏了我的代码中的一些内容并且不能解决我的问题"strictNullChecks": true,也没有效果//@ts-ignore线。这有效地消除了错误,并且测试顺利进行虽然我能够进行测试,但我不想在测试中到处都忽略这个错误,并且忽略错误只是一个好主意,直到它不是。
有人对这个问题有更多信息或建议吗?
此功能用于生成楼梯上的大步和短步的组合数(由用户给出的值).短步迈步1步,大步迈步2步.
但是,我不明白这里使用的递归洞察力.我真的很感激为什么会产生所需的组合数量.通过它,我可以看到它的工作原理,但我不确定自己将如何达到这个逻辑.
有人可以对此有所了解吗?
这是代码:
int CountWays(int numStairs);
int combination_strides = 0;
const int LARGE_STEP = 2;
const int SMALL_STEP = 1;
int main() {
cout << "Enter the number of stairs you wish to climb: ";
int response = GetInteger();
int combinations = CountWays(response);
cout << "The number of stride combinations is: " << combinations << endl;
return 0;
}
int CountWays(int numStairs) {
if (numStairs < 4) {
return numStairs;
} else {
return CountWays(numStairs - SMALL_STEP) + …Run Code Online (Sandbox Code Playgroud) 我正在使用Date对象在 javascript 中进行一些日期操作。我花了.toJSON()大约一个小时来理解一个错误:在初始化之后,我使用了函数,我的日期减一。这是我正在做的代码示例:
var date = new Date();
console.log(date.getDate()); // print "19"
date.setDate(date.getDate()-1); // print "18"
var formated = date.toJSON().substr(0, 10); // print "2013-09-17"
Run Code Online (Sandbox Code Playgroud)
突然,日期从 18 日变成了 17 日。所以可以肯定的是,我直接在开发人员控制台中尝试了这个:
new Date(2013, 09, 19)
Sat Oct 19 2013 00:00:00 GMT+0200 (Paris, Madrid (heure d’été)) // date "19" as it should
new Date(2013, 09, 19).toJSON()
"2013-10-18T22:00:00.000Z" // date "18" as it shouldn't
Run Code Online (Sandbox Code Playgroud)
现在我的问题只是“为什么?”。
这可能来自我的配置还是其他?
这是一个错误吗?如果是,它是一个已知的错误吗?