我有我的无服务器。下面的Yml
service: omy-api
provider:
name: aws
runtime: nodejs14.x
region: ${opt:region, 'us-east-1'}
stage: ${opt:stage, 'devint'}
memorySize: 128
timeout: 15
custom:
jest:
collectCoverage: true
functions:
- ${file(config/Customer/delete.yml)}
plugins:
- serverless-jest-plugin
在我的包。json中有
{
"name": "omy-api",
"version": "1.0.0",
"scripts": {
"deploy": "sls deploy",
"test": "jest"
},
"jest": {
"collectCoverage": true,
"coverageReporters": ["text-summary"],
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": -10
}
}
},
"author": "",
"license": "ISC",
"devDependencies": {
"serverless": "^1.83.3",
"serverless-jest-plugin": "^0.3.0",
},
"dependencies": {
"jest": "^27.0.6"
}
}
我遵循https://github.com/nordcloud/serverless-jest-plugin文档。当我运行sls调用测试时,我得到错误
Serverless错误 ----------------------------------------无服务器命令"调用测试"没有找到。运行"无服务器帮助";查看所有可用命令的列表。
我尝试了sls调用test—help,但是我得到了相同的错误。
如果您想通过输入如下命令来运行它,您必须首先安装全局使用的serverless和serverless插件,例如
npm install -g serverless
npm install -g serverless-jest-plugin
和运行
sls invoke test