小编pha*_*nan的帖子

使用 typescript 和 esm 运行 jest 时找不到模块“@middy/core”

你好,我正在使用 esm 和 jest 运行 typescript,但 middy 遇到问题:

\n

我做了这个测试:

\n
import { APIGatewayEvent, Context } from \'aws-lambda\';\nimport { lambda } from \'../index.js\';\n\ndescribe(\'get-by-id handler\', () => {\n  test(\'Should not find id\', async () => {\n    const x = jest.fn();\n    x();\n    expect(x).toHaveBeenCalled();\n  });\n});\n
Run Code Online (Sandbox Code Playgroud)\n

它与我在下面提供的配置和npm run test命令配合得很好。\n但是当我将其更改为如下所示时:

\n
import { APIGatewayEvent, Context } from \'aws-lambda\';\nimport { lambda } from \'../index.js\';\n\ndescribe(\'get-by-id handler\', () => {\n  test(\'Should not find id\', async () => {\n    const res = await lambda({\n    pathParameters: { …
Run Code Online (Sandbox Code Playgroud)

node.js typescript jestjs ts-jest middy

5
推荐指数
0
解决办法
562
查看次数

标签 统计

jestjs ×1

middy ×1

node.js ×1

ts-jest ×1

typescript ×1