Skip to content

Commit 883f5c1

Browse files
committed
fix e2e ci module wiring
1 parent 2a0a47d commit 883f5c1

3 files changed

Lines changed: 44 additions & 17 deletions

File tree

.github/workflows/e2e_android.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
steps:
2121
- name: Checkout react-native-update
2222
uses: actions/checkout@v6
23+
with:
24+
submodules: recursive
2325

2426
- name: Checkout react-native-update-cli
2527
uses: actions/checkout@v6
@@ -52,6 +54,18 @@ jobs:
5254
- name: Install e2etest dependencies
5355
run: cd Example/e2etest && bun install --frozen-lockfile
5456

57+
- name: Link local react-native-update
58+
run: |
59+
set -euo pipefail
60+
export LOCAL_RNU_VERSION="$(node -p "require('./Example/e2etest/node_modules/react-native-update/package.json').version")"
61+
LOCAL_RNU_DIR="$PWD/Example/e2etest/.e2e-artifacts/local-react-native-update"
62+
rm -rf "$LOCAL_RNU_DIR" Example/e2etest/node_modules/react-native-update
63+
mkdir -p "$LOCAL_RNU_DIR"
64+
cp package.json react-native-update.podspec react-native.config.js expo-module.config.json "$LOCAL_RNU_DIR"/
65+
rsync -a --exclude='.git' src ios android cpp scripts "$LOCAL_RNU_DIR"/
66+
node -e "const fs = require('fs'); const file = 'Example/e2etest/.e2e-artifacts/local-react-native-update/package.json'; const pkg = JSON.parse(fs.readFileSync(file, 'utf8')); pkg.version = process.env.LOCAL_RNU_VERSION; fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + '\n');"
67+
ln -s ../.e2e-artifacts/local-react-native-update Example/e2etest/node_modules/react-native-update
68+
5569
- name: Install react-native-update-cli dependencies
5670
run: cd react-native-update-cli && bun install --frozen-lockfile
5771

.github/workflows/e2e_ios.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
steps:
2020
- name: Checkout react-native-update
2121
uses: actions/checkout@v6
22+
with:
23+
submodules: recursive
2224

2325
- name: Checkout react-native-update-cli
2426
uses: actions/checkout@v6
@@ -53,6 +55,18 @@ jobs:
5355
- name: Install e2etest dependencies
5456
run: cd Example/e2etest && bun install --frozen-lockfile
5557

58+
- name: Link local react-native-update
59+
run: |
60+
set -euo pipefail
61+
export LOCAL_RNU_VERSION="$(node -p "require('./Example/e2etest/node_modules/react-native-update/package.json').version")"
62+
LOCAL_RNU_DIR="$PWD/Example/e2etest/.e2e-artifacts/local-react-native-update"
63+
rm -rf "$LOCAL_RNU_DIR" Example/e2etest/node_modules/react-native-update
64+
mkdir -p "$LOCAL_RNU_DIR"
65+
cp package.json react-native-update.podspec react-native.config.js expo-module.config.json "$LOCAL_RNU_DIR"/
66+
rsync -a --exclude='.git' src ios android cpp scripts "$LOCAL_RNU_DIR"/
67+
node -e "const fs = require('fs'); const file = 'Example/e2etest/.e2e-artifacts/local-react-native-update/package.json'; const pkg = JSON.parse(fs.readFileSync(file, 'utf8')); pkg.version = process.env.LOCAL_RNU_VERSION; fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + '\n');"
68+
ln -s ../.e2e-artifacts/local-react-native-update Example/e2etest/node_modules/react-native-update
69+
5670
- name: Install react-native-update-cli dependencies
5771
run: cd react-native-update-cli && bun install --frozen-lockfile
5872

src/__tests__/core.test.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test, mock } from 'bun:test';
1+
import { describe, expect, test, mock, spyOn } from 'bun:test';
22

33
// In Bun, top-level imports are cached.
44
// We can use mock.module to change the implementation of a module,
@@ -11,13 +11,16 @@ const importFreshCore = (cacheKey: string) => import(`../core?${cacheKey}`);
1111

1212
describe('core info parsing', () => {
1313
test('should call error when currentVersionInfo is invalid JSON', async () => {
14-
const mockError = mock(() => {});
14+
const consoleError = spyOn(console, 'error').mockImplementation(() => {});
1515

1616
mock.module('react-native', () => ({
1717
Platform: {
1818
OS: 'ios',
1919
Version: 13,
2020
},
21+
DeviceEventEmitter: {
22+
addListener: mock(() => ({ remove: mock(() => {}) })),
23+
},
2124
NativeModules: {
2225
Pushy: {
2326
currentVersionInfo: '{invalid}',
@@ -46,30 +49,30 @@ describe('core info parsing', () => {
4649
nanoid: () => 'mock-uuid',
4750
}));
4851

49-
mock.module('../utils', () => ({
50-
error: mockError,
51-
log: mock(() => {}),
52-
emptyModule: {},
53-
}));
54-
5552
// Use a unique query parameter to bypass cache if supported, or just rely on fresh environment per file.
5653
// In Bun, you can sometimes use a cache buster if it's dynamic import.
5754
await importFreshCore('error');
5855

59-
expect(mockError).toHaveBeenCalledWith(
56+
expect(consoleError).toHaveBeenCalledWith(
57+
expect.any(String),
6058
expect.stringContaining('error_parse_version_info')
6159
);
60+
61+
consoleError.mockRestore();
6262
});
6363

6464
test('should not call error when currentVersionInfo is valid JSON', async () => {
65-
const mockError = mock(() => {});
65+
const consoleError = spyOn(console, 'error').mockImplementation(() => {});
6666
const mockSetLocalHashInfo = mock(() => {});
6767

6868
mock.module('react-native', () => ({
6969
Platform: {
7070
OS: 'ios',
7171
Version: 13,
7272
},
73+
DeviceEventEmitter: {
74+
addListener: mock(() => ({ remove: mock(() => {}) })),
75+
},
7376
NativeModules: {
7477
Pushy: {
7578
currentVersionInfo: JSON.stringify({ name: 'v1', debugChannel: true }),
@@ -90,14 +93,10 @@ describe('core info parsing', () => {
9093
},
9194
}));
9295

93-
mock.module('../utils', () => ({
94-
error: mockError,
95-
log: mock(() => {}),
96-
emptyModule: {},
97-
}));
98-
9996
await importFreshCore('success');
10097

101-
expect(mockError).not.toHaveBeenCalled();
98+
expect(consoleError).not.toHaveBeenCalled();
99+
100+
consoleError.mockRestore();
102101
});
103102
});

0 commit comments

Comments
 (0)