用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill express-mocks-testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | express-mocks-testing |
| description | > Use when this capability is needed. |
new Server() or app from server.ts. It causes slow tests and port conflicts.jest.mock("@prisma/client", () => { ... }) to intercept Prisma Client instantiations before the controller executes.createRequest and createResponse from node-mocks-http to simulate Express objects.await controller.sendMessage(req, res)).jest.clearAllMocks() in the beforeEach hook.res._getJSONData() to verify JSON responses and res.statusCode to check HTTP statuses.import { createRequest, createResponse } from "node-mocks-http";
import { MyController } from "../my.controller";
import { PrismaClient } from "@prisma/client";
// 1. MOCK PRISMA GLOBALLY
jest.mock("@prisma/client", () => {
const mPrismaClient = {
user: {
findUnique: jest.fn(),
create: jest.fn(),
},
};
return { PrismaClient: jest.fn(() => mPrismaClient) };
});
const prismaMock = new PrismaClient() as jest.Mocked<any>;
describe("MyController", () => {
let controller: MyController;
beforeAll(() => {
controller = new MyController();
});
beforeEach(() => {
jest.clearAllMocks();
});
describe("getUser", () => {
it("should return 200 and the user data", async () => {
// Arrange
const req = createRequest({
method: "GET",
url: "/api/users/1",
params: { id: "1" },
user: { id_persona: "admin-123" } // If testing protected routes
});
const res = createResponse();
prismaMock.user.findUnique.mockResolvedValue({ id: "1", name: "John" });
// Act
await controller.getUser(req, res);
// Assert
expect(res.statusCode).toBe(200);
expect(res._getJSONData().name).toBe("John");
expect(prismaMock.user.findUnique).toHaveBeenCalledWith({
where: { id: "1" }
});
});
});
});
# Run backend tests
pnpm test
# Run specific test file
pnpm jest path/to/your/controller.test.ts
Source: davidleonmayor/proyecto-grado-unimayor — distributed by TomeVault.