From 43df4a33b29513ccad59be1327fb9d26fc85a17c Mon Sep 17 00:00:00 2001 From: Salakar Date: Mon, 24 Jun 2024 02:56:55 +0100 Subject: [PATCH] ci: fixes --- .github/workflows/ci.yml | 17 ++++++++++++++++- README.md | 4 ++-- example/.jetrc.js | 7 ++++++- example/App.tsx | 2 +- example/e2e/example.jet.ts | 1 + src/cli.ts | 14 +++++++------- src/index.tsx | 2 +- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab3ca8d..670fc63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: test: runs-on: macos-latest + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 @@ -32,9 +33,23 @@ jobs: - name: Setup uses: ./.github/actions/setup + - name: Start Metro Bundler + continue-on-error: true + working-directory: ./example + run: nohup sh -c "yarn start > metro.log 2>&1 &" + - name: Run unit tests working-directory: ./example - run: jet --target=macos --coverage + # TODO nyc breaks xcodebuild + # run: jet --target=macos --coverage + run: jet --target=macos + + - name: Upload Metro Log + uses: actions/upload-artifact@v4 + if: always() + with: + name: metro_log + path: metro.log build-library: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 745c4db..cc08f21 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ Jet lets you test your React Native Module APIs in JS mock free and native testi **Features:** - โฉ Test with JavaScript - write your native module tests in javascript and fully e2e test them. -- ๐Ÿ’ฏ Coverage - get full code coverage output for your React Native module's JS API with built in [istanbul/nyc](https://github.com/istanbuljs/nyc) coverage support (`--coverage`). -- +- ๐Ÿ’ฏ Coverage - get full code coverage output for your React Native module's JS API with built in coverage support (`--coverage`). + ![image](https://github.com/invertase/jet/assets/5347038/d0ca2c5b-7eee-48bb-94b5-21881455142d) diff --git a/example/.jetrc.js b/example/.jetrc.js index 34c59d6..b206592 100644 --- a/example/.jetrc.js +++ b/example/.jetrc.js @@ -19,7 +19,12 @@ module.exports = { * Use this to run builds, start the application etc. */ async before(config) { - proc.spawnSync('npx', ['react-native', 'run-macos']); + const process = proc.spawnSync('npx', ['react-native', 'run-macos']); + if (process.exitCode !== 0) { + console.log(process.stdout.toString()); + console.log(process.stderr.toString()); + throw new Error('Failed to build macos.'); + } return config; }, /** diff --git a/example/App.tsx b/example/App.tsx index 7e61b5f..ca22d16 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -17,7 +17,7 @@ ErrorUtils.setGlobalHandler((err, isFatal) => { throw err; }); -function loadTests(config: JetConfig) { +function loadTests(_: JetConfig) { const tests = (require as any).context('./e2e', true, /\.jet\.ts$/); tests.keys().forEach(tests); } diff --git a/example/e2e/example.jet.ts b/example/e2e/example.jet.ts index 4480537..b69a8b4 100644 --- a/example/e2e/example.jet.ts +++ b/example/e2e/example.jet.ts @@ -10,6 +10,7 @@ describe('test suite example', () => { }); }); +/* eslint-disable jest/no-disabled-tests */ it.skip('test skipping example', () => { return new Promise(resolve => setTimeout(resolve, 50)); }); diff --git a/src/cli.ts b/src/cli.ts index ed40537..be090a0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -89,8 +89,8 @@ async function startServer( config: z.infer, after: z.infer ): Promise { - server.on('started', (server) => { - const url = server.url; + server.on('started', (event) => { + const url = event.url; console.log(`[๐ŸŸฉ] Jet remote server listening at "${url}".`); }); @@ -328,11 +328,6 @@ yargs(hideBin(process.argv)) console.log('[๐Ÿš€] Starting tests...'); console.log('[๐Ÿงผ] Filter (--grep):', argv.grep || 'none'); console.log('[๐Ÿ”„] Invert filters:', argv.invert); - if (!(await isMetroRunning(argv.metroPort))) { - console.warn( - `[๐ŸŸจ] Metro is not running (${argv.metroPort} via '--metro-port' flag.). Start it before tests to enable stack trace symbolication.` - ); - } console.log('[๐Ÿช] Running before hook...'); const beforeHookReturnedConfig = await target.before?.(mergedConfig); if (!beforeHookReturnedConfig) { @@ -341,6 +336,11 @@ yargs(hideBin(process.argv)) ); process.exit(1); } + if (!(await isMetroRunning(argv.metroPort))) { + console.warn( + `[๐ŸŸจ] Metro is not running (${argv.metroPort} via '--metro-port' flag.). Start it before tests to enable stack trace symbolication.` + ); + } const finalConfig = JetConfigSchema.parse(beforeHookReturnedConfig)!; const server = new Server({ autoStart: false, diff --git a/src/index.tsx b/src/index.tsx index b85408d..cbe6149 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -137,7 +137,7 @@ export function JetProvider(props: JetProviderProps): React.JSX.Element { return () => { client.disconnect(); }; - }, [setStatus, setConfig, setConnected]); + }, [setStatus, setConfig, props]); return (