【发布时间】:2018-11-13 15:16:17
【问题描述】:
遵循此处的指南:https://firebase.google.com/docs/functions/unit-testing 我正在尝试为我的 TS 函数编写单元测试。 这是我的 package.json:
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"test": "mocha --reporter spec"
},
"main": "lib/index.js",
"dependencies": {
"@types/algoliasearch": "^3.27.0",
"@types/axios": "^0.14.0",
"@types/nodemailer": "^4.6.0",
"@types/stripe": "^5.0.11",
"algoliasearch": "^3.27.1",
"axios": "^0.18.0",
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.3",
"nodemailer": "^4.6.4",
"stripe": "^5.8.0",
"webpack": "^4.7.0"
},
"devDependencies": {
"@types/node": "^9.6.6",
"firebase-functions-test": "^0.1.2",
"mocha": "^5.2.0",
"ts-loader": "^4.2.0",
"tslint": "^5.8.0",
"typescript": "^2.8.3",
"webpack-cli": "^2.1.2",
"webpack-node-externals": "^1.7.2"
},
"private": true
}
我有 1 个问题和 1 个问题。
问题: 我无法导入 firebase-functions-test 在我的 index.test.ts 文件中。 它仅在依赖项中而不是在 devDependencies 中寻找它... (将其添加到依赖项中即可解决)。
问题: 我可以将所有 @types 移动到 devDependencies 吗?
谢谢。
【问题讨论】:
标签: unit-testing typescript firebase dependencies google-cloud-functions