-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgradle.test.ts
More file actions
69 lines (64 loc) · 2.29 KB
/
gradle.test.ts
File metadata and controls
69 lines (64 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import cp from "node:child_process";
import path from "node:path";
const PACKAGE_ROOT = path.join(__dirname, "../..");
const MONOREPO_ROOT = path.join(PACKAGE_ROOT, "../..");
const TEST_APP_ANDROID_PATH = path.join(MONOREPO_ROOT, "apps/test-app/android");
describe(
"Gradle tasks",
// Skipping these tests by default, as they download a lot and takes a long time
{ skip: process.env.ENABLE_GRADLE_TESTS !== "true" },
() => {
describe("linkNodeApiModules task", () => {
it("should fail if REACT_NATIVE_OVERRIDE_HERMES_DIR is not set", () => {
const { status, stdout, stderr } = cp.spawnSync(
"sh",
["gradlew", "react-native-node-api:linkNodeApiModules"],
{
cwd: TEST_APP_ANDROID_PATH,
env: {
...process.env,
REACT_NATIVE_OVERRIDE_HERMES_DIR: undefined,
},
encoding: "utf-8",
},
);
assert.notEqual(status, 0, `Expected failure: ${stdout} ${stderr}`);
assert.match(
stderr,
/React Native Node-API needs a custom version of Hermes with Node-API enabled/,
);
assert.match(
stderr,
/Run the following in your Bash- or Zsh-compatible terminal, to clone Hermes and instruct React Native to use it/,
);
assert.match(
stderr,
/export REACT_NATIVE_OVERRIDE_HERMES_DIR=\$\(npx react-native-node-api vendor-hermes --silent\)/,
);
assert.match(
stderr,
/And follow this guide to build React Native from source/,
);
});
it("should call the CLI to autolink", () => {
const { status, stdout, stderr } = cp.spawnSync(
"sh",
["gradlew", "react-native-node-api:linkNodeApiModules"],
{
cwd: TEST_APP_ANDROID_PATH,
env: {
...process.env,
// We're passing some directory which exists
REACT_NATIVE_OVERRIDE_HERMES_DIR: __dirname,
},
encoding: "utf-8",
},
);
assert.equal(status, 0, `Expected success: ${stdout} ${stderr}`);
assert.match(stdout, /Auto-linking Node-API modules/);
});
});
},
);