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

Revert mobile RN testsuite integration #11318

Merged
merged 2 commits into from
Oct 31, 2018
Merged
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
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ node_modules
test/e2e/test-plugins
vendor
packages/block-serialization-spec-parser/index.js
gutenberg-mobile
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion .stylelintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,44 +69,3 @@ jobs:
script:
- npm install || exit 1
- ./bin/run-e2e-tests.sh || exit 1
- stage: test
language: node_js
node_js: 8
env:
LANE='node'
GUTENBERG_AS_PARENT=true
CHECK_CORRECTNESS='true'
cache:
yarn: true
script:
- cd ./gutenberg-mobile
- yarn install
- ./.travis/travis-checks-js.sh
- stage: test
language: node_js
node_js: 8
env:
LANE='node'
GUTENBERG_AS_PARENT=true
CHECK_TESTS='true'
TEST_RN_PLATFORM='android'
cache:
yarn: true
script:
- cd ./gutenberg-mobile
- yarn install
- ./.travis/travis-checks-js.sh
- stage: test
language: node_js
node_js: 8
env:
LANE='node'
GUTENBERG_AS_PARENT=true
CHECK_TESTS='true'
TEST_RN_PLATFORM='ios'
cache:
yarn: true
script:
- cd ./gutenberg-mobile
- yarn install
- ./.travis/travis-checks-js.sh
25 changes: 0 additions & 25 deletions docs/reference/testing-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,30 +379,5 @@ Code style in PHP is enforced using [PHP_CodeSniffer](https://github.com/squizla

To run unit tests only, without the linter, use `npm run test-unit-php` instead.

## Native Mobile Testing

To enable automated testing against the native mobile app currently in development, the whole of the mobile source code is pulled in as a git submodule. Its testsuite is included in the Travis tests run but it can also be used locally, during development.

To test locally, along with the typical Gutenberg setup and testing instructions already mentioned earlier, make sure you check out the code of the submodule:
```
git submodule --init --recursive
```
You can then use the available script to launch the mobile testsuite in isolation:
```
npm run test-mobile
```

or the typical `npm run test` to run all the lint, unit and mobile tests in one go.

The mobile tests pick up the compiled Gutenberg code/packages and so, don't forget to run `npm install` (while at the Gutenberg root) after you've made changes to the code.

### Debugging native mobile

Say you have made some changes to Gutenberg's code and turns out the mobile tests get broken. What's the path forward? Hopefully, the Jest tests output will have an error message and stacktrace that is indicative enough and helps point where the error happens and what went wrong. Oftenly, what happens is that the code being shared between the web and the mobile project is no longer compatible.

For example, changing an intermediate interface can inadvertently bring the `file.js` and `file.native.js` pair out of sync. You'll then need to update the `.native.js` file to adhere to the new interface or iterate on the interface itself. Feel free to reach out to mobile devs for help if needed.

In other usual cases, you might directly employ HTML elements in a `render()` function but those are not actually offered by React Native, the UI framework the native mobile is build on. Those elements are usually starting with a lower-case character like `div` or `span`. In any case that code is incompatible or doesn't make sense for mobile, what needs to be done is to wrap that code in a new component and provide a "nativized" variant of it to be loaded when on native mobile instead. To "nativize" a component just create a new `.native.js` file right alongside the web version one and in it return/run the code that is compatible with mobile. The proper variant will be picked up by the toolchain automatically.

[snapshot testing]: https://facebook.github.io/jest/docs/en/snapshot-testing.html
[update snapshots]: https://facebook.github.io/jest/docs/en/snapshot-testing.html#updating-snapshots
1 change: 0 additions & 1 deletion gutenberg-mobile
Submodule gutenberg-mobile deleted from 776bb2
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
"webpack-bundle-analyzer": "3.0.2",
"webpack-cli": "2.1.3",
"webpack-livereload-plugin": "2.1.1",
"webpack-rtl-plugin": "github:yoavf/webpack-rtl-plugin#develop",
"yarn": "1.9.4"
"webpack-rtl-plugin": "github:yoavf/webpack-rtl-plugin#develop"
},
"npmPackageJsonLintConfig": {
"extends": "@wordpress/npm-package-json-lint-config",
Expand Down Expand Up @@ -169,20 +168,16 @@
"lint-css": "stylelint '**/*.scss'",
"lint-css:fix": "stylelint '**/*.scss' --fix",
"package-plugin": "./bin/build-plugin-zip.sh",
"mobile-submodule-update": "git submodule update --init --recursive",
"mobile-install": "yarn --cwd gutenberg-mobile install",
"preinstall": "npm run mobile-submodule-update",
"postinstall": " npm run mobile-install && npm run check-licenses && npm run build:packages",
"postinstall": "npm run check-licenses && npm run build:packages",
"pot-to-php": "./bin/pot-to-php.js",
"precommit": "lint-staged",
"publish:check": "npm run build:packages && lerna updated",
"publish:dev": "npm run build:packages && lerna publish --npm-tag next",
"publish:prod": "npm run build:packages && lerna publish",
"test": "concurrently \"npm run lint && npm run test-unit\" \"npm run test-mobile\"",
"test": "npm run lint && npm run test-unit",
"pretest-e2e": "concurrently \"./bin/reset-e2e-tests.sh\" \"npm run build\"",
"test-e2e": "cross-env JEST_PUPPETEER_CONFIG=test/e2e/puppeteer.config.js wp-scripts test-unit-js --config test/e2e/jest.config.json --runInBand",
"test-e2e:watch": "npm run test-e2e -- --watch",
"test-mobile": "yarn --cwd gutenberg-mobile test:inside-gb",
"test-php": "npm run lint-php && npm run test-unit-php",
"test-unit": "wp-scripts test-unit-js --config test/unit/jest.config.json",
"test-unit:coverage": "npm run test-unit -- --coverage",
Expand Down
9 changes: 1 addition & 8 deletions test/e2e/jest.config.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
{
"rootDir": "../../",
"coveragePathIgnorePatterns": [
"/node_modules/",
"<rootDir>/gutenberg-mobile/"
],
"preset": "jest-puppeteer",
"setupTestFrameworkScriptFile": "<rootDir>/test/e2e/support/setup-test-framework.js",
"testMatch": [
"<rootDir>/test/e2e/specs/**/(*.)test.js"
],
"transform": {
"^.+\\.jsx?$": "<rootDir>/node_modules/babel-jest"
},
"modulePathIgnorePatterns": [
"<rootDir>/gutenberg-mobile/"
]
}
}
6 changes: 1 addition & 5 deletions test/unit/jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"<rootDir>/.*/build/",
"<rootDir>/.*/build-module/",
"<rootDir>/packages/.*/benchmark/",
"<rootDir>/packages/.*/test/",
"<rootDir>/gutenberg-mobile/"
"<rootDir>/packages/.*/test/"
],
"moduleNameMapper": {
"@wordpress\\/(block-serialization-spec-parser|is-shallow-equal)$": "packages/$1",
Expand All @@ -23,8 +22,5 @@
"/test/e2e",
"<rootDir>/.*/build/",
"<rootDir>/.*/build-module/"
],
"modulePathIgnorePatterns": [
"<rootDir>/gutenberg-mobile/"
]
}