reactjs - AWS Amplify Deploy(构建和测试)React JS + Jest + Enzyme
问题描述
我在 AWS Amplify 上部署了一个 React JS 项目,一切正常。但是我有一些测试脚本,我想在 Amplify 在每次部署时部署一个新版本之前运行它们。问题是当我更改为amplify.yml
在构建代码之前尝试运行我的测试脚本时,它现在不再完成构建(无限加载而没有完成构建和部署)。
amplify.yml
更改前:
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
appRoot: burger-builder
amplify.yml
更改后:
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- test:
phases:
preTest:
commands:
- npm ci
test:
commands:
- npm run test
appRoot: burger-builder
解决方案
By default, create-react-app
runs your Jest tests in interactive mode. To understand what that means, run npm run test
in your terminal and note that you'll have to change some code or hit 'a' to actually run your tests. You don't want this behavior in your Amplify deploy process. In the amplify.yml file, run your tests in non-interactive mode with npm test -- --watchAll=false
. Or with yarn, yarn test --watchAll=false
.
推荐阅读
- php - 选择当前用户的所有朋友的ID?
- java - 如何在 Mapbox SDK 的 LineString 上设置文本?
- python-3.x - PyCharm 看不到本地安装的包
- r - 从父环境调用缺少的参数
- spring-boot - 为什么 Spring Boot 有两种不同的 ReactiveX 实现?
- postgresql - io.crate.shade.org.postgresql.util.PSQLException:致命:用户“ABC”的信任身份验证失败
- javascript - Suitescript 2.0 ResultSet.Each 回调函数超过 4000
- java - 二维数组网格玩家运动 Java
- python - 使用带有格式化输出的 Python 进行数据探索
- node.js - 创建 Mongoose/MongoDB 常量文档