Skip to content

Commit

Permalink
feat: added next workflow for universal
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhk20 committed Sep 19, 2024
1 parent f6b9080 commit d3383fe
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 27 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/gluestack-expo-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ jobs:
working-directory: ${{ env.working-directory }}
run: |
yarn web --port 19006 &
echo $! > expo_pid.txt
sleep 60 # Wait for Expo to start
- name: Run tests
working-directory: ${{ env.working-directory }}
run: yarn test

- name: Kill Expo server
run: |
kill $(cat expo_pid.txt)
19 changes: 4 additions & 15 deletions .github/workflows/universal-gluestack-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,10 @@ jobs:
- name: Install dependencies
run: yarn

- name: Install dependencies for Next app
working-directory: ${{ env.working-directory }}/apps/next
run: yarn

- name: Build Next
working-directory: ${{ env.working-directory }}
run: yarn build:next

- name: Start Expo on port 19007
working-directory: ${{ env.working-directory }}
run: |
cd apps/expo-app && yarn start:web --port 19007 &
echo $! > expo_pid.txt
sleep 60 # Wait for Expo to start
- name: Run tests
working-directory: ${{ env.working-directory }}
run: yarn test

- name: Kill Expo server
run: |
kill $(cat expo_pid.txt)
10 changes: 10 additions & 0 deletions universal/apps/expo-app/__tests__/expo-app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import { render, screen } from "@testing-library/react-native";
import App from "../app/index";

test("renders correctly", () => {
render(<App />);

// Check if a specific text or element is present in the component
expect(screen.getByText("SplashScreen")).toBeTruthy();
});
15 changes: 15 additions & 0 deletions universal/apps/expo-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
preset: "jest-expo",
roots: ["<rootDir>/__tests__"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testEnvironment: "jsdom",
transformIgnorePatterns: [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg|@gluestack-ui/.*|tailwind-variants)",
],
setupFilesAfterEnv: ["@testing-library/jest-native/extend-expect"],
collectCoverageFrom: ["app/**/*.{ts,tsx}"],
reporters: ["default", "jest-junit"],

testMatch: ["<rootDir>/__tests__/**/*.test.(js|jsx)"],
forceExit: true,
};
3 changes: 3 additions & 0 deletions universal/apps/expo-app/junit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="0" failures="0" errors="0" time="7.441">
</testsuites>
8 changes: 4 additions & 4 deletions universal/apps/expo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"android": "EXPO_USE_METRO_WORKSPACE_ROOT=1 npx expo start --android",
"ios": "EXPO_USE_METRO_WORKSPACE_ROOT=1 npx expo start --ios",
"web": "EXPO_USE_METRO_WORKSPACE_ROOT=1 npx expo start --web",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
"test": "jest"
},
"dependencies": {
"@expo/vector-icons": "^14.0.0",
Expand All @@ -37,11 +34,14 @@
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@testing-library/jest-native": "^5.4.3",
"@testing-library/react-native": "^12.7.2",
"@types/react": "~18.2.45",
"@unitools/babel-plugin-universal-image": "^1.0.0",
"babel-plugin-module-resolver": "^5.0.2",
"jest": "^29.2.1",
"jest-expo": "~51.0.1",
"jest-junit": "^16.0.0",
"react-test-renderer": "18.2.0",
"typescript": "~5.3.3"
},
Expand Down
1 change: 1 addition & 0 deletions universal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"run:expo": "cd apps/expo-app && yarn start",
"run:next": "cd apps/next && yarn dev",
"build:next": "cd apps/next && yarn build",
"test:expo": "cd apps/expo-app && yarn test",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\" --ignore-path .gitignore",
"postinstall": "patch-package",
"eject": "npx @gluestack-ui/universal-cli@latest eject"
Expand Down
49 changes: 46 additions & 3 deletions universal/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3962,6 +3962,26 @@
dependencies:
tslib "^2.4.0"

"@testing-library/jest-native@^5.4.3":
version "5.4.3"
resolved "https://registry.yarnpkg.com/@testing-library/jest-native/-/jest-native-5.4.3.tgz#9334c68eaf45db9eb20d0876728cc5d7fc2c3ea2"
integrity sha512-/sSDGaOuE+PJ1Z9Kp4u7PQScSVVXGud59I/qsBFFJvIbcn4P6yYw6cBnBmbPF+X9aRIsTJRDl6gzw5ZkJNm66w==
dependencies:
chalk "^4.1.2"
jest-diff "^29.0.1"
jest-matcher-utils "^29.0.1"
pretty-format "^29.0.3"
redent "^3.0.0"

"@testing-library/react-native@^12.7.2":
version "12.7.2"
resolved "https://registry.yarnpkg.com/@testing-library/react-native/-/react-native-12.7.2.tgz#d9dc62979264902c22ac9154eee0dc10914d1518"
integrity sha512-fSUIruOUFcuwssC8+m9H+9ib7P/+JrtIszHS4eZ6O9e4FjpjS3m24UnkJXTRl+FCbknz8oxH5Tw+thzy0qsIMg==
dependencies:
jest-matcher-utils "^29.7.0"
pretty-format "^29.7.0"
redent "^3.0.0"

"@tootallnate/once@2":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
Expand Down Expand Up @@ -7978,7 +7998,7 @@ jest-config@^29.7.0:
slash "^3.0.0"
strip-json-comments "^3.1.1"

jest-diff@^29.7.0:
jest-diff@^29.0.1, jest-diff@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a"
integrity sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==
Expand Down Expand Up @@ -8074,6 +8094,16 @@ jest-haste-map@^29.7.0:
optionalDependencies:
fsevents "^2.3.2"

jest-junit@^16.0.0:
version "16.0.0"
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-16.0.0.tgz#d838e8c561cf9fdd7eb54f63020777eee4136785"
integrity sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==
dependencies:
mkdirp "^1.0.4"
strip-ansi "^6.0.1"
uuid "^8.3.2"
xml "^1.0.1"

jest-leak-detector@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz#5b7ec0dadfdfec0ca383dc9aa016d36b5ea4c728"
Expand All @@ -8082,7 +8112,7 @@ jest-leak-detector@^29.7.0:
jest-get-type "^29.6.3"
pretty-format "^29.7.0"

jest-matcher-utils@^29.7.0:
jest-matcher-utils@^29.0.1, jest-matcher-utils@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz#ae8fec79ff249fd592ce80e3ee474e83a6c44f12"
integrity sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==
Expand Down Expand Up @@ -10220,7 +10250,7 @@ pretty-format@^26.5.2, pretty-format@^26.6.2:
ansi-styles "^4.0.0"
react-is "^17.0.1"

pretty-format@^29.7.0:
pretty-format@^29.0.3, pretty-format@^29.7.0:
version "29.7.0"
resolved "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz"
integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==
Expand Down Expand Up @@ -10689,6 +10719,14 @@ recast@^0.23.3:
tiny-invariant "^1.3.3"
tslib "^2.0.1"

redent@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f"
integrity sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==
dependencies:
indent-string "^4.0.0"
strip-indent "^3.0.0"

reflect.getprototypeof@^1.0.4:
version "1.0.4"
resolved "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz"
Expand Down Expand Up @@ -12594,6 +12632,11 @@ [email protected]:
sax ">=0.6.0"
xmlbuilder "~11.0.0"

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==

xmlbuilder@^14.0.0:
version "14.0.0"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-14.0.0.tgz#876b5aec4f05ffd5feb97b0a871c855d16fbeb8c"
Expand Down

0 comments on commit d3383fe

Please sign in to comment.