diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab3ca8d..5f7f30d 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,21 @@ 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 + run: jet --target=macos --coverage + + - 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/example/.jetrc.js b/example/.jetrc.js index 34c59d6..45faae8 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.status !== 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 (