-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfake-tests.ts
More file actions
42 lines (36 loc) · 1009 Bytes
/
fake-tests.ts
File metadata and controls
42 lines (36 loc) · 1009 Bytes
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
import path from "node:path";
import { spawn, SpawnFailure } from "bufout";
import { Client } from "mocha-remote-client";
const cwd = path.resolve(__dirname, "..");
const env = {
...process.env,
FORCE_COLOR: "1",
};
const metro = spawn("react-native", ["start", "--no-interactive"], {
cwd,
stdio: "inherit",
outputPrefix: "[metro] ",
env,
});
process.once("SIGTERM", () => {
console.log("Received SIGTERM, shutting down metro server...");
metro.kill();
});
// Create a client, which will automatically connect to the server on the default port (8090)
const client = new Client({
// Called when the server asks the client to run
tests: () => {
// write your tests here or require a package that calls the mocha globals
describe("my thing", () => {
it("works", async () => {
// yay!
await new Promise((resolve) => setTimeout(resolve, 1000));
});
});
},
});
metro.catch((err) => {
if (!(err instanceof SpawnFailure)) {
throw err;
}
});