Skip to content

Commit

Permalink
more refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobar79 committed Dec 21, 2024
1 parent 241d064 commit b789020
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/macstadium-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,12 @@ jobs:
run: |
sed -i'' -e "s/IS_TESTING=false/IS_TESTING=true/" .env && rm -f .env-e
yarn detox build --configuration ios.sim.release
- name: Detox iOS e2e tests serial
run: |
./scripts/run-serial-e2e.sh
- name: Detox iOS e2e tests parallel
run: |
./scripts/run-parallel-e2e.sh 3
./scripts/run-parallel-e2e.sh
- name: Detox iOS e2e tests serial
run: |
./scripts/run-serial-e2e.sh 3
4 changes: 2 additions & 2 deletions e2e/serial/1_sendSheetFlowContacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const android = device.getPlatform() === 'android';

describe('Send Sheet Interaction Flow Contacts', () => {
beforeAll(async () => {
await beforeAllcleanApp({ anvil: true });
await beforeAllcleanApp({});
});
afterAll(async () => {
await afterAllcleanApp({ anvil: true });
await afterAllcleanApp({});
});

it('Import a wallet and go to welcome', async () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/serial/2_swaps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import { WALLET_VARS } from '../testVariables';

describe('Swap Sheet Interaction Flow', () => {
beforeAll(async () => {
await beforeAllcleanApp({ anvil: true });
await beforeAllcleanApp({});
});
afterAll(async () => {
await afterAllcleanApp({ anvil: true });
await afterAllcleanApp({});
});

it('Import a wallet and go to welcome', async () => {
Expand Down
13 changes: 12 additions & 1 deletion scripts/run-parallel-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#!/bin/bash

./node_modules/.bin/detox test ./e2e/parallel/ -c ios.sim.release --maxWorkers 2 --R 3

# 0) Read build type from first argument; default to "release" if not specified
BUILD_TYPE=${1:-release} # can be "debug" or "release"

# 0.1) Decide Detox config based on BUILD_TYPE
if [ "$BUILD_TYPE" = "debug" ]; then
DETOX_CONFIG="ios.sim.debug"
else
DETOX_CONFIG="ios.sim.release"
fi

./node_modules/.bin/detox test ./e2e/parallel/ -c "$DETOX_CONFIG" --maxWorkers 2 --R 3
50 changes: 49 additions & 1 deletion scripts/run-serial-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
#!/bin/bash
set -e

./node_modules/.bin/detox test ./e2e/serial/ -c ios.sim.release --maxWorkers 1 --R 3
# 0) Read build type from first argument; default to "release" if not specified
BUILD_TYPE=${1:-release} # can be "debug" or "release"

# 0.1) Decide Detox config based on BUILD_TYPE
if [ "$BUILD_TYPE" = "debug" ]; then
DETOX_CONFIG="ios.sim.debug"
else
DETOX_CONFIG="ios.sim.release"
fi

# Loop through each file in the ./e2e/serial/ directory
for test_file in ./e2e/serial/*.ts; do
echo "====================================="
echo "Running test file: $test_file"
echo "====================================="

# 1) Start Anvil in the background (show logs in terminal + save to file)
yarn anvil 2>&1 | grep -v "eth_" | tee anvil.log &
ANVIL_PID=$!

# 2) Wait for Anvil to initialize
sleep 5

# 3) Run Detox for this single file
./node_modules/.bin/detox test "$test_file" -c "$DETOX_CONFIG" --maxWorkers 1 --R 3
ret_val=$?

# 4) Kill the Anvil process
echo "Killing Anvil (PID: $ANVIL_PID)"
kill "$ANVIL_PID"

# 5) Wait for Anvil to truly exit
wait "$ANVIL_PID" 2>/dev/null || true

# 5.1) Remove the Anvil log file
rm -rf anvil.log

# 6) Decide what to do if Detox failed or succeeded
if [ "$ret_val" -ne 0 ]; then
echo "❌ Tests failed for $test_file"
exit 1 # or break, depending on your preference
else
echo "✅ Tests passed for $test_file"
fi

done

echo "✅ All tests passed for every file!"
exit 0

0 comments on commit b789020

Please sign in to comment.