小编fxl*_*ire的帖子

默认情况下使用`--disable-gpu`标志启动VS代码

由于硬件加速,我在VS Code中出现滞后峰值.

如何让VS Code始终使用标志--disable-gpu启动(从命令行启动时以及从上下文菜单启动)?

windows-10 visual-studio-code

5
推荐指数
1
解决办法
1420
查看次数

如何使用 Jest 仅为特定测试模拟模块的功能

我需要模拟依赖项的功能,但仅限于特定的测试用例。在我的其他测试中,我想保持模块不变。我也在嘲笑其他模块。那些需要保持嘲笑。

我尝试了多种方法,因为这个问题的许多变体都被问到了,但是由于我需要在不被嘲笑的情况下使用原始模块,所以其他解决方案似乎都不起作用......

这是我需要的一个例子

// 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)

unit-testing typescript jestjs

5
推荐指数
1
解决办法
4768
查看次数