我无法使用 Xcode 12.5 构建使用 Xcode 11 正确构建的 React Native 项目。
我不能再使用 Xcode 11,因为只有更新的 Xcode 版本才带有必要的 API 来发布/上传到 TestFlight 和应用商店。
现在我收到三个构建错误:
Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
Cannot initialize a parameter of type 'NSArray<id<RCTBridgeModule>> *' with an rvalue of type 'NSArray<Class> *'
Run Code Online (Sandbox Code Playgroud)
我还注意到部署目标从 10 和 9 自动升级:
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.1;
Run Code Online (Sandbox Code Playgroud)
添加了一些与 Clang …
我尝试测试反应本机组件,但出现此错误。
我意识到错误来自文件import Convertor, { ConvertorComponent } from '../components/Convertor.js
中的声明convertor.test.js
。export ConvertorComponent
我用和导出了组件export default Convertor
。
const warnedKeys: {[string]: boolean} = {};
SyntaxError: Missing initializer in const declaration
at ScriptTransformer.transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
at Object.<anonymous> (node_modules/react-native/Libraries/react-native/react-native-implementation.js:14:18)
Run Code Online (Sandbox Code Playgroud) 请注意,我已阅读文档,并参考了发生错误的点以及我采取的步骤。请不要建议我按照我已经指出的说明进行操作。
在尽我所能遵循React Native的文档之后,我一直无法让 React Native 运行。我已经按照说明安装了 jdk、node 和 Android Studio(使用 Chocolatey 和链接)。Android 模拟器从 Android Studio 运行。我使用的是 npm 版本 6.1.0、节点版本 8.4.0、jdk 8、Android Studio 3.1.3。我得到的错误react-native init AwesomeProject
是SyntaxError: Unexpected token import
. 我做错了什么?我怎样才能解决这个问题?运行react-native run-android
也会出现同样的错误。
需要明确的是,我在正确的目录中。ANDROID_HOME
设置为正确的sdk
文件夹。有一个标题 ,Running your React Native application
并且运行第一个命令会给我留下错误,但在那之前我没有收到错误。
有没有办法调用fetch
Jest 测试?我只想调用实时 API 以确保它仍在工作。如果有 500 个错误或数据不是我所期望的,那么测试应该报告。
我注意到request
从http
模块中使用不起作用。调用fetch
,就像我通常在不用于测试的代码中所做的那样,将给出错误:Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
当我在浏览器中调用 API 时,它会在不到一秒的时间内返回。我使用大约以下内容来进行测试,但我也只是fetch
从测试中返回了该函数,而没有使用done
类似的失败:
import { JestEnvironment } from "@jest/environment";
import 'isomorphic-fetch';
import { request, } from "http";
jest.mock('../MY-API');
describe('tests of score structuring and display', () => {
test('call API - happy path', (done) => {
fetch(API).then(
res => res.json()
).then(res => {
expect(Array.isArray(response)).toBe(true);
console.log(`success: ${success}`);
done();
}).catch(reason …
Run Code Online (Sandbox Code Playgroud) react-native ×4
jestjs ×2
reactjs ×2
android ×1
asynchronous ×1
enzyme ×1
ios ×1
javascript ×1
xcode ×1