我需要在AWS amplify中为创建react应用程序设置构建管道。我找不到代码片段来添加使用Jest和React测试库和typescript的单元测试。你能分享一下有jest单元测试的amplify.yml吗?我在下面试过了
version: 1
frontend:
phases:
preBuild:
commands: ['npm ci']
build:
commands: 'npm run test' && 'npm run build'
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- 'node_modules/**/*'发布于 2021-03-13 06:44:33
要添加Jest,首先应该确保它已安装并列在package.json文件中。
在项目的根目录中:
npm install jest --save-dev
您还应该将以下内容添加到package.json:
"scripts":{ "test":"jest“},
然后通过运行以下命令在本地运行Jest
npm运行测试
如果可以,您只需要确保jest在您的构建环境中可用。
Package.json:
{
"name": "Your-app-name",
"author": "",
"license": "",
"homepage": "",
"version": "1.0.0",
"description": "xxx",
"scripts": {
"test": "jest"
},
"devDependencies": {
"jest": "^26.6.3",
"uuid": "^8.3.2"
}
}希望能对你有所帮助!
https://stackoverflow.com/questions/64850890
复制相似问题