未找到无服务器命令 "invoke test"。 运行 "serverless help" 获取所有可用命令的列表

Serverless command "invoke test" not found. Run "serverless help" for a list of all available commands

我的 serverless.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

在我的 package.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 Error ---------------------------------------- Serverless command "invoke test" not found. Run "serverless help" for a list of all available commands.

我尝试了 sls invoke test --help,但我得到了同样的错误。

如果你想运行它通过输入如下命令,你必须首先安装无服务器和你全局使用的无服务器插件,例如

npm install -g serverless

npm install -g serverless-jest-plugin

和运行

sls invoke test