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

Yarn workspace test fixture #681

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
56 changes: 56 additions & 0 deletions fixtures/monorepo-react_native_windows_current/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [[`module:${require.resolve('../../packages/haul-babel-preset-react-native')}`, { chakra: true }]],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.document = {};
19 changes: 19 additions & 0 deletions fixtures/monorepo-react_native_windows_current/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"workspaces": {
"packages": [
"packages/*"
]
},
"private": true,
"scripts": {
"build": "yarn workspaces run build:all",
"test": "yarn workspace app0 run test"
},
"dependencies": {
},
"engines": {
"node": ">=10.12.0 <=12.2.0",
"yarn": ">=1.15.0",
"npm": ">=6.4.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { mount } from 'enzyme';
import App from '../index.windows';

let subject;
afterEach(() => {
subject.unmount();
});

test('Renders content rating image', () => {
subject = mount(<App />);

expect(subject).toBeTruthy();
});

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../babel.config');
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { withPolyfills, makeConfig } from '../../../../packages/haul-preset-0.59';

const PLATFORM_COMMON = {
platform: 'windows',
providesModuleNodeModules: ['react-native', 'react-native-windows'],
hasteOptions: { platforms: ['native', 'windows'] },
};

export default makeConfig({
server: { host: '0.0.0.0' },
platforms: ['windows'],
bundles: {
index: {
entry: withPolyfills('./App'),
sourceMap: true,
...PLATFORM_COMMON,
transform: ({ config }) => {
// config.plugins.push(new DuplicatePackageChecker());
return config;
},
}
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { Counter } from '@components/component-library';

export default class App extends Component {
render() {
return <Counter />;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
preset: 'react-native',
setupFiles: [require.resolve('react-native/jest/setup'), './jest.setup.js'],
setupFilesAfterEnv: [require.resolve('jest-enzyme/lib')],
transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation|@react-navigation|@react-native-community)',
],
testMatch: ['<rootDir>/**/__tests__/**/*[.-_](spec|test).[tj]s?(x)'],
transform: {
'^.+\\.[jt]sx?$': 'babel-jest',
'.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|dds|ogg|json.resource)$':
require.resolve('react-native/jest/assetFileTransformer.js'),
},
// FIXME: fix jest so this manual line isn't necessary
rootDir: '../..'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "app0",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "haul start",
"test": "jest"
},
"dependencies": {
"@components/component-library": "*",
"react": "16.8.3",
"react-native": "0.59.8",
"react-native-windows": "0.59.0-rc.3"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"metro-react-native-babel-preset": "^0.56.0",
"rnpm-plugin-windows": "^0.2.11",
"babel-jest": "^24.8.0",
"enzyme": "^3.9.0",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"jest-enzyme": "^7.0.2",
"metro-react-native-babel-preset": "^0.54.0",
"react-dom": "16.8.3",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { mount } from 'enzyme';
import Counter from '../index.windows.js';

let subject;
afterEach(() => {
subject.unmount();
});

test('Renders content rating image', () => {
subject = mount(<Counter />);

expect(subject).toBeTruthy();
});

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../babel.config');
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { withPolyfills, makeConfig } from '../../../../packages/haul-preset-0.59';

const PLATFORM_COMMON = {
platform: 'windows',
providesModuleNodeModules: ['react-native', 'react-native-windows'],
hasteOptions: { platforms: ['native', 'windows'] },
};

export default makeConfig({
server: { host: '0.0.0.0' },
platforms: ['windows'],
bundles: {
index: {
entry: withPolyfills('./App'),
sourceMap: true,
...PLATFORM_COMMON,
transform: ({ config }) => {
// config.plugins.push(new DuplicatePackageChecker());
return config;
},
}
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { ProgressBarWindows } from 'react-native-windows';

const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
windows:
'Shake cuz YOLO',
});

export default class App extends Component {
state = {
counter: 0,
}

render() {
const loadTime = Math.abs(Date.now() - this.props.navigation.state.params.loadStartTimestamp);
return (
<View style={styles.container}>
<Text style={styles.welcome}>App 0</Text>
<Text style={styles.body}>Load time: {loadTime} ms</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
<Text style={styles.instructions}>Counter: {this.state.counter}</Text>
<TouchableOpacity onPress={() => {
this.setState(state => ({ counter: state.counter + 1 }))
}}><Text style={styles.instructions}>Increment</Text></TouchableOpacity>
<ProgressBarWindows progress={this.state.counter} />
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 36,
textAlign: 'center',
color: '#282828',
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
body: {
fontSize: 24,
textAlign: 'center',
color: '#282828',
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
preset: 'react-native',
setupFiles: [require.resolve('react-native/jest/setup')],
setupFilesAfterEnv: [require.resolve('jest-enzyme/lib')],
transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation|@react-navigation|@react-native-community)',
],
testMatch: ['<rootDir>/**/__tests__/**/*[.-_](spec|test).[tj]s?(x)'],
transform: {
'^.+\\.[jt]sx?$': 'babel-jest',
'.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|dds|ogg|json.resource)$':
require.resolve('react-native/jest/assetFileTransformer.js'),
},
// FIXME: fix jest so this manual line isn't necessary
rootDir: '../..'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@components/component-library",
"version": "0.0.1",
"private": true,
"main": "index.windows.js",
"scripts": {
"start": "haul start",
"test": "jest"
},
"peerDependencies": {
"react": ">= 16.8.3",
"react-native": ">= 0.59.8",
"react-native-windows": "0.59.0-rc.3"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"metro-react-native-babel-preset": "^0.56.0",
"rnpm-plugin-windows": "^0.2.11",
"babel-jest": "^24.8.0",
"enzyme": "^3.9.0",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"jest-enzyme": "^7.0.2",
"metro-react-native-babel-preset": "^0.54.0",
"react-dom": "16.8.3",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
Loading