由于硬件加速,我在VS Code中出现滞后峰值.
如何让VS Code始终使用标志--disable-gpu启动(从命令行启动时以及从上下文菜单启动)?
我需要模拟依赖项的功能,但仅限于特定的测试用例。在我的其他测试中,我想保持模块不变。我也在嘲笑其他模块。那些需要保持嘲笑。
我尝试了多种方法,因为这个问题的许多变体都被问到了,但是由于我需要在不被嘲笑的情况下使用原始模块,所以其他解决方案似乎都不起作用......
这是我需要的一个例子
// app.ts
import * as moduleA from 'moduleA';
// ...
app.post('/signup', async (req, res) => {
// ...
const hashed = await moduleA.hash(req.body.password);
// ...
});
export default app;
// app.test.ts
// some mocks
jest.mock('./database', () => ({ ... }));
// ...
import * as request from 'supertest';
import app from './app';
// ...
describe('A', () => {
test('Those should work', async () => {
const response = await request(app).post('/signup').send({ password: 'pw' });
expect(response.status).toBe(200);
// ...
}); …Run Code Online (Sandbox Code Playgroud)