Skip to content

Commit

Permalink
fix(tests, emulator): centralize startup, correct CWD
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed Nov 10, 2020
1 parent 70974d4 commit 79c1f80
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/scripts/start-firestore-emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ if ! [ -x "$(command -v firebase)" ]; then
exit 1
fi

firebase emulators:start --only firestore &
EMU_START_COMMAND="firebase emulators:start --only firestore"

until curl --output /dev/null --silent --fail http://localhost:8080; do
echo "Waiting for Firestore emulator to come online..."
sleep 2
done

echo "Firestore emulator is online!"
if [ "$1" == "--no-daemon" ]; then
$EMU_START_COMMAND
else
$EMU_START_COMMAND &
until curl --output /dev/null --silent --fail http://localhost:8080; do
echo "Waiting for Firestore emulator to come online..."
sleep 2
done
echo "Firestore emulator is online!"
fi
4 changes: 2 additions & 2 deletions .github/workflows/tests_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
command: npm i -g firebase-tools

- name: Start Firestore Emulator
run: cd ./.github/workflows/scripts && sh ./start-firestore-emulator.sh
run: yarn tests:emulator:start-ci

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
command: npm i -g firebase-tools

- name: Start Firestore Emulator
run: cd ./.github/workflows/scripts && sh ./start-firestore-emulator.sh
run: yarn tests:emulator:start-ci

- name: Get Xcode version
id: xcode-version
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"tests:packager:chrome": "cd tests && node_modules/.bin/react-native start --reset-cache",
"tests:packager:jet": "cd tests && cross-env REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive",
"tests:packager:jet-reset-cache": "cd tests && cross-env REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --reset-cache --no-interactive",
"tests:emulator:start": "./tests/node_modules/.bin/firebase emulators:start --only firestore",
"tests:emulator:start": "cd ./.github/workflows/scripts && sh ./start-firestore-emulator.sh --no-daemon",
"tests:emulator:start-ci": "cd ./.github/workflows/scripts && sh ./start-firestore-emulator.sh",
"tests:android:build": "cd tests && ./node_modules/.bin/detox build --configuration android.emu.debug",
"tests:android:build-release": "cd tests && ./node_modules/.bin/detox build --configuration android.emu.release",
"tests:android:test": "cd tests && ./node_modules/.bin/detox test --configuration android.emu.debug",
Expand Down
11 changes: 5 additions & 6 deletions packages/app/e2e/config.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ describe('config', () => {
});

// NOTE: "preferencesClearAll" clears Firestore settings. Set DB as emulator again.
// FIXME if we use the emulator, then we never throw errors because firestore rules are permissive, that causes test failure
// after(async () => {
// await firebase
// .firestore()
// .settings({ host: 'localhost:8080', ssl: false, persistence: true });
// });
after(async () => {
await firebase
.firestore()
.settings({ host: 'localhost:8080', ssl: false, persistence: true });
});

it('should set bool values', async () => {
const prefsBefore = await NativeModules.RNFBAppModule.preferencesGetAll();
Expand Down

1 comment on commit 79c1f80

@vercel
Copy link

@vercel vercel bot commented on 79c1f80 Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.