4

使用带有单元测试模块的serverless框架时serverless-offline出现持续错误。jest

我正在尝试使用serverless-jest-plugin应该集成jestserverless. 以下是我的jest配置serverless.yml

custom:
 default:
  stage: dev
 table:
  dictionary: Dictionary
  rules: Rules
 jest:
  verbose: true
  testResultsProcessor: jest-junit
  modulePaths: ["<rootDir>/node_modules", "<rootDir>/lib"]
  roots: ["<rootDir>/tests"]
  testEnvironment: node
plugins:
   - serverless-jest-plugin
   - serverless-dynamodb-local
   - serverless-offline

我有一个 lambda 函数,它使用 dynamoDB 来获取一些数据等。

每当我使用时sls invoke test,我都有以下内容:

$ sls invoke test
 FAIL  tests/file.test.js
  ● Test suite failed to run

TypeError: Path must be a string. Received undefined

  at assertPath (path.js:7:11)
  at Object.relative (path.js:1226:5)
  at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.386s
Ran all test suites.

我正在运行以下内容package.json

{
  "dependencies": {
    "ajv": "^6.1.1",
    "async": "^2.6.0",
    "aws-sdk": "^2.188.0",
    "notevil": "^1.1.0"
  },
  "devDependencies": {
    "jest": "^22.2.1",
    "jest-junit": "^3.5.0",
    "serverless-dynamodb-local": "^0.2.27",
    "serverless-jest-plugin": "^0.1.6",
    "serverless-offline": "^3.16.0"
  }
}

干杯。

4

0 回答 0