Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repro Nx Detox/Metro Issue #185

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,62 @@ testem.log
# System Files
.DS_Store
Thumbs.db

# React Native

## Xcode

**/ios/**/build/
**/ios/**/*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

## Android

**/android/**/build/
**/android/**/.gradle
**/android/**/local.properties
**/android/**/*.iml

## BUCK

buck-out/
\.buckd/
*.keystore
!debug.keystore

## fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
#
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

## Bundle artifact
*.jsbundle

## CocoaPods
**/ios/Pods/
/

## Nested node_modules

node_modules/

apps/applesauce-e2e/artifacts
11 changes: 11 additions & 0 deletions apps/applesauce-e2e/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic"
}
]
],
"plugins": []
}
58 changes: 58 additions & 0 deletions apps/applesauce-e2e/.detoxrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"testRunner": "jest",
"runnerConfig": "jest.config.json",
"apps": {
"ios.debug": {
"type": "ios.app",
"build": "cd ../applesauce/ios && xcodebuild -workspace Applesauce.xcworkspace -scheme Applesauce -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet",
"binaryPath": "../applesauce/ios/build/Build/Products/Debug-iphonesimulator/Applesauce.app"
},
"ios.release": {
"type": "ios.app",
"build": "cd ../applesauce/ios && xcodebuild -workspace Applesauce.xcworkspace -scheme Applesauce -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' -derivedDataPath ./build -quiet",
"binaryPath": "../applesauce/ios/build/Build/Products/Release-iphonesimulator/Applesauce.app"
},
"android.debug": {
"type": "android.apk",
"build": "cd ../applesauce/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug",
"binaryPath": "../applesauce/android/app/build/outputs/apk/debug/app-debug.apk"
},
"android.release": {
"type": "android.apk",
"build": "cd ../applesauce/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release",
"binaryPath": "../applesauce/android/app/build/outputs/apk/release/app-release.apk"
}
},
"devices": {
"simulator": {
"type": "ios.simulator",
"device": {
"type": "iPhone 13"
}
},
"emulator": {
"type": "android.emulator",
"device": {
"avdName": "Pixel_4a_API_30"
}
}
},
"configurations": {
"ios.sim.release": {
"device": "simulator",
"app": "ios.release"
},
"ios.sim.debug": {
"device": "simulator",
"app": "ios.debug"
},
"android.emu.release": {
"device": "emulator",
"app": "android.release"
},
"android.emu.debug": {
"device": "emulator",
"app": "android.debug"
}
}
}
18 changes: 18 additions & 0 deletions apps/applesauce-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
23 changes: 23 additions & 0 deletions apps/applesauce-e2e/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const {
DetoxCircusEnvironment,
SpecReporter,
WorkerAssignReporter,
} = require('detox/runners/jest-circus');

class CustomDetoxEnvironment extends DetoxCircusEnvironment {
constructor(config, context) {
super(config, context);

// Can be safely removed, if you are content with the default value (=300000ms)
this.initTimeout = 300000;

// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
// This is strictly optional.
this.registerListeners({
SpecReporter,
WorkerAssignReporter,
});
}
}

module.exports = CustomDetoxEnvironment;
12 changes: 12 additions & 0 deletions apps/applesauce-e2e/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"preset": "../../jest.preset",
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 120000,
"reporters": ["detox/runners/jest/streamlineReporter"],
"setupFilesAfterEnv": ["<rootDir>/test-setup.ts"],
"transform": {
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nrwl/react/plugins/jest",
"^.+\\.[tj]sx?$": "babel-jest"
}
}
64 changes: 64 additions & 0 deletions apps/applesauce-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"root": "apps/applesauce-e2e",
"sourceRoot": "apps/applesauce-e2e/src",
"projectType": "application",
"targets": {
"build-ios": {
"executor": "@nrwl/detox:build",
"options": {
"detoxConfiguration": "ios.sim.debug"
},
"configurations": {
"production": {
"detoxConfiguration": "ios.sim.release"
}
}
},
"test-ios": {
"executor": "@nrwl/detox:test",
"options": {
"detoxConfiguration": "ios.sim.debug",
"buildTarget": "applesauce-e2e:build-ios"
},
"configurations": {
"production": {
"detoxConfiguration": "ios.sim.release",
"buildTarget": "applesauce-e2e:build-ios:prod"
}
}
},
"build-android": {
"executor": "@nrwl/detox:build",
"options": {
"detoxConfiguration": "android.emu.debug"
},
"configurations": {
"production": {
"detoxConfiguration": "android.emu.release"
}
}
},
"test-android": {
"executor": "@nrwl/detox:test",
"options": {
"detoxConfiguration": "android.emu.debug",
"buildTarget": "applesauce-e2e:build-android"
},
"configurations": {
"production": {
"detoxConfiguration": "android.emu.release",
"buildTarget": "applesauce-e2e:build-android:prod"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/applesauce-e2e/**/*.{ts,tsx,js,jsx}"]
}
}
},
"tags": [],
"implicitDependencies": ["applesauce"]
}
11 changes: 11 additions & 0 deletions apps/applesauce-e2e/src/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { device, element, by, expect } from 'detox';

describe('Applesauce', () => {
beforeEach(async () => {
await device.reloadReactNative();
});

it('should display welcome message', async () => {
await expect(element(by.id('heading'))).toHaveText('Welcome Applesauce 👋');
});
});
6 changes: 6 additions & 0 deletions apps/applesauce-e2e/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { device } from 'detox';

beforeAll(async () => {
await device.launchApp();
await device.disableSynchronization();
});
10 changes: 10 additions & 0 deletions apps/applesauce-e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["node", "jest", "detox"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}
10 changes: 10 additions & 0 deletions apps/applesauce-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.e2e.json"
}
]
}
3 changes: 3 additions & 0 deletions apps/applesauce/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["module:metro-react-native-babel-preset"]
}
20 changes: 20 additions & 0 deletions apps/applesauce/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*", "public", ".cache", "node_modules"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@typescript-eslint/ban-ts-comment": "off"
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
55 changes: 55 additions & 0 deletions apps/applesauce/android/app/_BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []

create_aar_targets(glob(["libs/*.aar"]))

create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = "build_config",
package = "com.applesauce",
)

android_resource(
name = "res",
package = "com.applesauce",
res = "src/main/res",
)

android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)