简体   繁体   中英

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

I have my serverless.yml like below

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

in my package.json I have

{
  "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"
  }
}

am following the https://github.com/nordcloud/serverless-jest-plugin documentation. when i run sls invoke test, I get the error

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

I tried sls invoke test --help, but I get the same error.

If you want to run it by entering a command like below, you must first install serverless and the serverless plugins you use globally, for example

npm install -g serverless

npm install -g serverless-jest-plugin

and run

sls invoke test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM