From 7fc8f9f6342b13a0a5b9d65fc170b7749ced3483 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 8 May 2025 09:37:16 +0200 Subject: [PATCH] test: starting with 0.80, JSC is no longer available --- example/test/specs/app.spec.mjs | 7 ++++--- scripts/testing/test-matrix.mts | 24 +++++++++++++++++------- scripts/types.ts | 1 + 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/example/test/specs/app.spec.mjs b/example/test/specs/app.spec.mjs index a029843a7..e0cddfc89 100644 --- a/example/test/specs/app.spec.mjs +++ b/example/test/specs/app.spec.mjs @@ -1,5 +1,5 @@ // @ts-check -import { equal } from "node:assert/strict"; +import { equal, match } from "node:assert/strict"; import { after, before, describe, it } from "node:test"; import { remote } from "webdriverio"; import { findNearest, readTextFile } from "../../../scripts/helpers.js"; @@ -103,8 +103,9 @@ describe("App", () => { const reactNative = await client.$(byId("react-native-value")); equal(await reactNative.getText(), reactNativeVersion); - const hermes = await client.$(byId("hermes-value")); - equal(await hermes.getText(), getCapability("react:hermes")); + const jsEngine = await client.$(byId("js-engine-value")); + const isHermes = config.capabilities["react:hermes"]; + match(await jsEngine.getText(), isHermes ? /^Hermes/ : /^JSC$/); const fabric = await client.$(byId("fabric-value")); equal(await fabric.getText(), getCapability("react:fabric")); diff --git a/scripts/testing/test-matrix.mts b/scripts/testing/test-matrix.mts index 3aee7ba93..8ca92fee8 100644 --- a/scripts/testing/test-matrix.mts +++ b/scripts/testing/test-matrix.mts @@ -6,7 +6,7 @@ import { spawn, spawnSync } from "node:child_process"; import * as fs from "node:fs"; import { URL, fileURLToPath } from "node:url"; import * as util from "node:util"; -import { readTextFile } from "../helpers.js"; +import { readTextFile, toVersionNumber, v } from "../helpers.js"; import { setReactVersion } from "../internal/set-react-version.mts"; import type { BuildConfig, TargetPlatform } from "../types.js"; import { green, red, yellow } from "../utils/colors.mjs"; @@ -43,7 +43,17 @@ const PLATFORM_CONFIG: Record = { ios: { name: "iOS", engines: ["jsc", "hermes"], - isAvailable: () => process.platform === "darwin", + isAvailable: ({ version, engine }) => { + if (process.platform !== "darwin") { + return false; + } + + if (engine === "jsc" && toVersionNumber(version) >= v(0, 80, 0)) { + return false; + } + + return true; + }, prebuild: installPods, }, macos: { @@ -203,7 +213,7 @@ function buildAndRun(platform: TargetPlatform) { } } -async function buildRunTest({ platform, variant }: BuildConfig) { +async function buildRunTest({ version, platform, variant }: BuildConfig) { const setup = PLATFORM_CONFIG[platform]; if (!setup) { log(yellow(`⚠ Unknown platform: ${platform}`)); @@ -211,7 +221,7 @@ async function buildRunTest({ platform, variant }: BuildConfig) { } for (const engine of setup.engines) { - const configWithEngine = { platform, variant, engine }; + const configWithEngine = { version, platform, variant, engine }; if (!setup.isAvailable(configWithEngine)) { continue; } @@ -285,13 +295,13 @@ if (platforms.length === 0) { return job.then(() => withReactNativeVersion(version, async () => { for (const platform of platforms) { - await buildRunTest({ platform, variant }); + await buildRunTest({ version, platform, variant }); } }) ); }, prestart()) .then(() => { - showBanner(`Initialize new app`); + showBanner("Initialize new app"); $( PACKAGE_MANAGER, "init-test-app", @@ -306,7 +316,7 @@ if (platforms.length === 0) { ); }) .then(() => { - showBanner(`Reconfigure existing app`); + showBanner("Reconfigure existing app"); const args = [ "configure-test-app", "-p", diff --git a/scripts/types.ts b/scripts/types.ts index b1e7886f4..a55d8bf86 100644 --- a/scripts/types.ts +++ b/scripts/types.ts @@ -310,6 +310,7 @@ export type ApplePlatform = "ios" | "macos" | "visionos"; export type TargetPlatform = ApplePlatform | "android" | "windows"; export type BuildConfig = { + version: string; platform: TargetPlatform; variant: "fabric" | "paper"; engine?: "hermes" | "jsc";