This repository has been archived by the owner on Feb 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
1,584 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,6 @@ testem.log | |
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Local Circleci | ||
process.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
preset: '../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'], | ||
maxWorkers: 1, | ||
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } }, | ||
displayName: 'e2e-detox', | ||
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'], | ||
testTimeout: 600000, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { join } from 'path'; | ||
import { | ||
ensureNxProject, | ||
patchPackageJsonForPlugin, | ||
runPackageManagerInstall, | ||
} from '@nrwl/nx-plugin/testing'; | ||
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; | ||
import { readJsonFile, writeJsonFile } from '@nrwl/devkit'; | ||
|
||
beforeAll(() => { | ||
// delete @nrlw/detox form react-native package.json so it will not pull @nrwl/detox from npm registry and use local one | ||
const path = join(appRootPath, 'dist/packages/react-native/package.json'); | ||
const json = readJsonFile(path); | ||
delete json.dependencies['@nrwl/detox']; | ||
writeJsonFile(path, json); | ||
}); | ||
|
||
beforeEach(() => { | ||
ensureNxProject('@nrwl/detox', 'dist/packages/detox'); | ||
patchPackageJsonForPlugin('@nrwl/react-native', 'dist/packages/react-native'); | ||
runPackageManagerInstall(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { readJsonFile, writeJsonFile } from '@nrwl/devkit'; | ||
import { runNxCommandAsync, uniq } from '@nrwl/nx-plugin/testing'; | ||
import { platform } from 'os'; | ||
|
||
describe('Detox iOS', () => { | ||
// Currently there is known issue that for react native 0.65rc, Folly dual symbols preventing ios from building successfully. | ||
xtest('should pass detox e2e tests on ios', async () => { | ||
if (platform() !== 'darwin') { | ||
return; | ||
} | ||
const myapp = uniq('myapp'); | ||
await runNxCommandAsync( | ||
`generate @nrwl/react-native:app ${myapp} --e2eTestRunner=detox --linter=eslint` | ||
); | ||
|
||
const androidBuildResult = await runNxCommandAsync( | ||
`build-ios ${myapp}-e2e` | ||
); | ||
expect(androidBuildResult.stdout).toContain('BUILD SUCCESS'); | ||
|
||
const androidTestResult = await runNxCommandAsync( | ||
`test-ios ${myapp}-e2e --cleanup` | ||
); | ||
expect(androidTestResult.stdout).toContain( | ||
'Running target "test-ios" succeeded' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.e2e.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.spec.ts", "**/*.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { join } from 'path'; | ||
import { | ||
ensureNxProject, | ||
patchPackageJsonForPlugin, | ||
runPackageManagerInstall, | ||
} from '@nrwl/nx-plugin/testing'; | ||
import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; | ||
import { readJsonFile, writeJsonFile } from '@nrwl/devkit'; | ||
|
||
beforeAll(() => { | ||
// delete @nrlw/detox form react-native package.json so it will not pull @nrwl/detox from npm registry and use local one | ||
const path = join(appRootPath, 'dist/packages/react-native/package.json'); | ||
const json = readJsonFile(path); | ||
delete json.dependencies['@nrwl/detox']; | ||
writeJsonFile(path, json); | ||
}); | ||
|
||
beforeEach(() => { | ||
ensureNxProject('@nrwl/detox', 'dist/packages/detox'); | ||
patchPackageJsonForPlugin('@nrwl/react-native', 'dist/packages/react-native'); | ||
runPackageManagerInstall(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Detox Plugin for Nx | ||
|
||
[![License](https://img.shields.io/npm/l/@nrwl/workspace.svg?style=flat-square)]() | ||
[![NPM Version](https://badge.fury.io/js/%40nrwl%2Fdetox.svg)](https://www.npmjs.com/@nrwl/detox) | ||
[![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![Join us @nrwl/community on slack](https://img.shields.io/badge/slack-%40nrwl%2Fcommunity-brightgreen)](https://join.slack.com/t/nrwlcommunity/shared_invite/enQtNzU5MTE4OTQwOTk0LTgxY2E0ZWYzMWE0YzA5ZDA2MWM1NDVhNmI2ZWMyYmZhNWJiODk3MjkxZjY3MzU5ZjRmM2NmNWU1OTgyZmE4Mzc) | ||
|
||
</div> | ||
|
||
## Table of Contents | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Setup](#setup) | ||
- [Install applesimutils (Mac only)](#install-applesimutils-mac-only) | ||
- [Install Jest Globally](#install-jest-globally) | ||
- [Commands](#commands) | ||
- [Manually Add E2E Folder](#manually-add-e2e-folder) | ||
- [Change Testing Simulator/Emulator](#change-testing-simulatoremulator) | ||
- [Learn more](#learn-more) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## Setup | ||
|
||
#### Install applesimutils (Mac only) | ||
|
||
[applesimutils](https://github.com/wix/AppleSimulatorUtils) is a collection of utils for Apple simulators. | ||
|
||
```sh | ||
brew tap wix/brew | ||
brew install applesimutils | ||
``` | ||
|
||
#### Install Jest Globally | ||
|
||
```sh | ||
npm install -g jest | ||
``` | ||
|
||
### Commands | ||
|
||
A built app must exist before run test commands. | ||
|
||
- `nx build-ios <app-name-e2e>`: build the iOS app (Mac only) | ||
- `nx test-ios <app-name-e2e>`: run e2e tests on the built iOS app (Mac only) | ||
- `nx build-ios <app-name-e2e> --prod` and `nx test-ios <app-name-e2e> --prod`: build and run release version of iOS app. Note: you might need open the xcode project under iOS and choose a team under "Sign & Capabilities". | ||
- `nx build-android <app-name-e2e>`: build the android app | ||
- `nx test-android <app-name-e2d>`: run e2e tests on the built android app | ||
- `nx build-android <app-name-e2e> --prod` and `nx test-android <app-name-e2e> --prod`: build and run release version of android app. | ||
|
||
### Manually Add E2E Folder | ||
|
||
A `<app-name-e2e>` folder is automatically generate when you create a react native app. However, if you want to add e2e folder manually, you need to: | ||
|
||
- Install @nrwl/detox | ||
|
||
```sh | ||
# Using npm | ||
npm install --save-dev @nrwl/detox | ||
|
||
# Using yarn | ||
yarn add -D @nrwl/detox | ||
``` | ||
|
||
- Run `nx generate @nrwl/detox:app <app-name-e2e>` | ||
- Follow instructions https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md to manully change android files. | ||
|
||
### Change Testing Simulator/Emulator | ||
|
||
For iOS, in terminal, run `xcrun simctl list` to view a list of simulators on your Mac. To open your active simulator, `run open -a simulator`. In `<app-name-e2e>/.detoxrc.json`, you could change the simulator under `devices.simulator.device`. | ||
|
||
For Android: in terminal, run `emulator -list-avds` to view a list of emulators installed. To open your emulator, run `emulator -avd <your emulator name>`. In `<app-name-e2e>/.detoxrc.json`, you could change the simulator under `devices.emulator.device`. | ||
|
||
## Learn more | ||
|
||
Visit the [Nx Documentation](https://nx.dev) to learn more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"executors": { | ||
"build": { | ||
"implementation": "./src/executors/build/build.impl", | ||
"schema": "./src/executors/build/schema.json", | ||
"description": "Run the command defined in build property of the specified configuration." | ||
}, | ||
"test": { | ||
"implementation": "./src/executors/test/test.impl", | ||
"schema": "./src/executors/test/schema.json", | ||
"description": "Initiating your detox test suite." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "Nx Detox", | ||
"version": "0.1", | ||
"extends": ["@nrwl/workspace"], | ||
"schematics": { | ||
"init": { | ||
"factory": "./src/generators/init/init#detoxInitGenerator", | ||
"schema": "./src/generators/init/schema.json", | ||
"description": "Initialize the @nrwl/detox plugin", | ||
"hidden": true | ||
}, | ||
"application": { | ||
"factory": "./src/generators/application/application#detoxApplicationSchematic", | ||
"schema": "./src/generators/application/schema.json", | ||
"aliases": ["app"], | ||
"description": "Create an application" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { detoxInitGenerator } from './src/generators/init/init'; | ||
export { detoxApplicationGenerator } from './src/generators/application/application'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
preset: '../../jest.preset.js', | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html', 'json'], | ||
globals: { | ||
'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' }, | ||
}, | ||
displayName: 'react-native', | ||
testEnvironment: 'node', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Oops, something went wrong.