From 1f0d6ff101ee6b371bb79981f7447a4323990c0a Mon Sep 17 00:00:00 2001 From: Warley Lopes Date: Sun, 19 May 2024 18:17:34 -0400 Subject: [PATCH] ci: move detox artifacts folder --- .github/workflows/actions.yml | 2 +- .gitignore | 2 +- README.md | 13 +++++++++---- native-app/.detoxrc.js | 9 +++++++++ native-app/e2e/jest.config.js | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 0cd2f36..3432bf1 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -126,4 +126,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: detox-artifacts - path: native-app/artifacts/ + path: native-app/e2e/test-assets/artifacts/ diff --git a/.gitignore b/.gitignore index f5ed759..37256b6 100644 --- a/.gitignore +++ b/.gitignore @@ -133,7 +133,7 @@ dist .netlify # detox artifacts -native-app/artifacts +**/artifacts/* # snapshot artifact native-app/components/__tests__/__snapshots__/**.snap \ No newline at end of file diff --git a/README.md b/README.md index ebec34e..90f023c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This repository showcases mobile test automation for a React Native project usin - [Unit Tests for Components - Jest](./native-app/components/__tests__/MachineScore.test.tsx) - [Unit Tests for the API - Jest](./backend/__tests__/calculate.test.ts) - [API Test Automation - Axios Request](./backend/__tests__/api.test.ts) -- [Detox Artifacts](./native-app/artifacts/) +- [Detox Artifacts](./native-app/e2e/test-assets/artifacts/) - [Jest Test Coverage from Unit Tests - Mobile App](./native-app/coverage/lcov-report/index.html) - [Jest Test Coverage from Unit Tests - API](./backend/coverage/lcov-report/index.html) - [Mobile Components/UI Snapshots](./native-app/components/__tests__/__snapshots__/) @@ -48,10 +48,15 @@ Make sure you have [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#instal 6. In a new terminal window, navigate to `./native-app/` 7. Run `nvm install` 8. Install dependencies: `yarn install` -9. Run the build with: `yarn detox:build` -10. Run the tests with: `yarn detox:test` +9. Run the build for iOS with: `yarn detox:build:ios` +10. Run the tests for iOS with: `yarn detox:test:ios` +11. For Android, make sure you have an android emulator in Android Studio named as `Pixel_3a_API_31_x86_64` +12. Make sure the android emulator is created with the API_31 and x86_64 architecture +13. Run the build for Android with: `yarn detox:build:android` +14. Run the tests for Android with: `yarn detox:test:android` -Artifacts for the run will be generated in case of any failing tests inside the [artifacts](./native-app/artifacts/) folder. + +Artifacts for the run will be generated in case of any failing tests inside the [artifacts](./native-app/e2e/test-assets/artifacts/) folder. ## Mobile Components Unit Testing diff --git a/native-app/.detoxrc.js b/native-app/.detoxrc.js index 389e82d..6de0e5a 100644 --- a/native-app/.detoxrc.js +++ b/native-app/.detoxrc.js @@ -74,5 +74,14 @@ module.exports = { device: 'emulator', app: 'android.debug' } + }, + artifacts: { + rootDir: 'e2e/test-assets/artifacts/', + plugins: { + screenshot: { + shouldTakeAutomaticSnapshots: true, + keepOnlyFailedTestsArtifacts: true + } + } } }; diff --git a/native-app/e2e/jest.config.js b/native-app/e2e/jest.config.js index fd1e978..f9f76c8 100644 --- a/native-app/e2e/jest.config.js +++ b/native-app/e2e/jest.config.js @@ -11,7 +11,7 @@ module.exports = { [ 'jest-junit', { - outputDirectory: '/artifacts/reports/', + outputDirectory: '/e2e/test-assets/artifacts/reports/', outputName: 'test_results.xml' } ]