From 52958cd5103c6c41cde98f80f6601e4fed32421e Mon Sep 17 00:00:00 2001 From: Dratwas Date: Mon, 18 Nov 2019 16:08:17 +0100 Subject: [PATCH 1/2] iOS e2e fix --- babel.config.js | 10 +++++----- package-lock.json | 4 ++++ packages/react-native-editor/babel.config.js | 2 -- .../ios/gutenberg.xcodeproj/project.pbxproj | 2 +- packages/react-native-editor/rn-cli.config.js | 1 - rn-cli.config.js | 1 + .../native}/jest_ui.config.js | 6 ------ test/unit/jest.config.js | 1 + 8 files changed, 12 insertions(+), 15 deletions(-) create mode 100644 rn-cli.config.js rename {packages/react-native-editor => test/native}/jest_ui.config.js (65%) diff --git a/babel.config.js b/babel.config.js index f950b6603a5127..43aee7a092b581 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,8 +1,8 @@ +const config = process.env.MOBILE ? require( './packages/react-native-editor/babel.config' ) : { + presets: [ '@wordpress/babel-preset-default' ], + plugins: [ 'babel-plugin-inline-json-import' ], +}; module.exports = function( api ) { api.cache( true ); - - return { - presets: [ '@wordpress/babel-preset-default' ], - plugins: [ 'babel-plugin-emotion', 'babel-plugin-inline-json-import' ], - }; + return config; }; diff --git a/package-lock.json b/package-lock.json index da9d1f42c252f4..e9dfd3e56e7b41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7231,6 +7231,7 @@ "@wordpress/i18n": "file:packages/i18n", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/rich-text": "file:packages/rich-text", "@wordpress/token-list": "file:packages/token-list", "@wordpress/url": "file:packages/url", @@ -7273,6 +7274,7 @@ "@wordpress/i18n": "file:packages/i18n", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/rich-text": "file:packages/rich-text", "@wordpress/server-side-render": "file:packages/server-side-render", "@wordpress/url": "file:packages/url", @@ -7525,6 +7527,7 @@ "@wordpress/notices": "file:packages/notices", "@wordpress/nux": "file:packages/nux", "@wordpress/plugins": "file:packages/plugins", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/url": "file:packages/url", "@wordpress/viewport": "file:packages/viewport", "classnames": "^2.2.5", @@ -7580,6 +7583,7 @@ "@wordpress/media-utils": "file:packages/media-utils", "@wordpress/notices": "file:packages/notices", "@wordpress/nux": "file:packages/nux", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/rich-text": "file:packages/rich-text", "@wordpress/server-side-render": "file:packages/server-side-render", "@wordpress/url": "file:packages/url", diff --git a/packages/react-native-editor/babel.config.js b/packages/react-native-editor/babel.config.js index fe85eb62619c59..497719de10803d 100644 --- a/packages/react-native-editor/babel.config.js +++ b/packages/react-native-editor/babel.config.js @@ -1,5 +1,3 @@ -/** @format */ - module.exports = { presets: [ 'module:metro-react-native-babel-preset' ], plugins: [ diff --git a/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj b/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj index 56261cc8ff99d0..14cdd71dc5dab3 100644 --- a/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj +++ b/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj @@ -1339,7 +1339,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../../../node_modules/react-native/scripts/react-native-xcode.sh\n"; + shellScript = "export NODE_BINARY=node\nexport MOBILE=true\n../../../node_modules/react-native/scripts/react-native-xcode.sh packages/react-native-editor/index.js\n"; }; 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = { isa = PBXShellScriptBuildPhase; diff --git a/packages/react-native-editor/rn-cli.config.js b/packages/react-native-editor/rn-cli.config.js index 6ba929fc2e5263..e04a7aa2a40da4 100644 --- a/packages/react-native-editor/rn-cli.config.js +++ b/packages/react-native-editor/rn-cli.config.js @@ -6,7 +6,6 @@ const path = require( 'path' ); const enm = require( './extra-node-modules.config.js' ); module.exports = { - projectRoot: path.resolve( __dirname, './' ), resolver: { extraNodeModules: enm, sourceExts: [ 'js', 'json', 'scss', 'sass' ], diff --git a/rn-cli.config.js b/rn-cli.config.js new file mode 100644 index 00000000000000..670b07eecd8b4f --- /dev/null +++ b/rn-cli.config.js @@ -0,0 +1 @@ +module.exports = require( './packages/react-native-editor/rn-cli.config' ); diff --git a/packages/react-native-editor/jest_ui.config.js b/test/native/jest_ui.config.js similarity index 65% rename from packages/react-native-editor/jest_ui.config.js rename to test/native/jest_ui.config.js index adf98100cde478..89d66b615b59ef 100644 --- a/packages/react-native-editor/jest_ui.config.js +++ b/test/native/jest_ui.config.js @@ -1,6 +1,3 @@ -/** @flow - * @format */ - const main = require( './jest.config.js' ); module.exports = { @@ -10,8 +7,5 @@ module.exports = { testMatch: [ '**/__device-tests__/**/*.test.[jt]s?(x)' ], testPathIgnorePatterns: [ '/node_modules/', - '/gutenberg/gutenberg-mobile/', - '/gutenberg/test/', - '/gutenberg/packages/', ], }; diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index 6ad2de76e69ef2..c2be67100c21e0 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -25,6 +25,7 @@ module.exports = { '/.*/build/', '/.*/build-module/', '/.+\.native\.js$', + '/packages/react-native-editor', ], transform: { '^.+\\.[jt]sx?$': '/test/unit/scripts/babel-transformer.js', From 009243e6ef8f0b48dad9fa77542dbe8ed837bcbf Mon Sep 17 00:00:00 2001 From: Dratwas Date: Thu, 5 Dec 2019 16:00:09 +0100 Subject: [PATCH 2/2] change babel caching and add comment about native tests --- babel.config.js | 2 +- test/unit/jest.config.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/babel.config.js b/babel.config.js index 43aee7a092b581..e500371df49e2d 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,6 +3,6 @@ const config = process.env.MOBILE ? require( './packages/react-native-editor/bab plugins: [ 'babel-plugin-inline-json-import' ], }; module.exports = function( api ) { - api.cache( true ); + api.cache.using( () => process.env.MOBILE ? 'mobile' : 'web' ); return config; }; diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index c2be67100c21e0..0a468d4a735d73 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -25,6 +25,7 @@ module.exports = { '/.*/build/', '/.*/build-module/', '/.+\.native\.js$', + // This is temporary. In the future we should change the names of the native tests files to .native.js. '/packages/react-native-editor', ], transform: {