Home of The Times' react
/react native
components, using
react-native-web to share across
platforms
We require MacOS with Node.js (version >=8.10.0 < 10> with npm v5), yarn (latest) and watchman installed. Native development requires Xcode, Android Studio, JDK 8 and pip.
You can try without these requirements, but you'd be on your own.
Go to http://components.thetimes.co.uk
-
Install fontforge:
brew install fontforge
(See Fonts section) -
Run
yarn install
-
Components can be seen running in a storybook:
- web storybook
yarn storybook
- go to http://localhost:9001
- native storybook
yarn storybook-native
and leave it runningyarn ios
to start the iOS app- To start the Android app:
- Start a virtual device
- Check Android SDK path is exported to $ANDROID_HOME. In Mac, android sdk
is installed to ~/Library/Android/sdk by default.
export ANDROID_HOME="/Users/<USERNAME>/Library/Android/sdk"
yarn android
- If you get build errors, check your JDK version with
javac -version
, which should printjavac 1.8.XXXX
. Earlier or later versions may not work.
- go to http://localhost:7007
In order to run development servers for native applications, start react-native dev server via:
yarn android:app
or yarn ios:app
For step by step guide, see the corresponding Readme documentation for android and ios
In order to view the storybook on native, you'll need to fix broken fonts. This fix is done automatically when running storybook (both web and native), but requires that fontforge is installed, otherwise the fix won't be applied and you'll get the classic red error screen when trying to use a broken font.
See utils package on how to update the schema
The components in this project can be debugged through your browser's developer tools. These steps assume the use of Chrome DevTools.
To debug our web Storybook:
yarn storybook
- navigate to http://localhost:9001
- open DevTools
- Click Sources
- In the Network tab under the leftmost pane, expand top => storybook-preview-iframe => webpack:// => . => packages
Any of these source files can be debugged directly.
To debug our native Storybook:
yarn storybook-native
and leave it runningyarn android:logs
oryarn ios:logs
(this will build storybook app and output logs) 2a. Or you could just runyarn android
oryarn ios
to just build the apps- open the developer menu on your device (Cmd + M on Android, Cmd + D on iOS) and tap Debug JS Remotely
- navigate to http://localhost:8081/debugger-ui if it hasn't opened automatically
- open DevTools
- click Sources
- expand debuggerWorker.js => webpack:// => . => packages
Follow these steps here
Tests | Covered | CI |
---|---|---|
Unit tests, UI tests and Integration tests | ✅ | Travis Build |
Visual Regression tool (Dextrose) | ✅ | Not automated |
Functional Regression tool (Fructose) | ✅ | Not automated |
Tests are currently using jest to run so if you want to debug any test follow these steps:
-
(FIND YOUR TEST COMMAND)
jest --config="./packages/provider/__tests__/jest.config.js"
. Depending on what directory we start the tests from, the--config
directory may differ. My currenct directory is at the repo root:times-components
. -
See your test command from the
package.json
for the speciffic package you want to check out.
NOTE: If you don't have jest installed globally, you can use it locally from the
node_modules/.bin/jest
- (START TESTS IN DEBUG MODE) We need to start the same command but through node while in debug mode like so:
node --inspect-brk ./node_modules/.bin/jest --config="./packages/provider/__tests__/jest.config.js" --runInBand
NOTE:
--runInBand
is ajest
flag that runs all tests serially in the current process. If we don't add this flag, only the node process that startedjest
will be debuggable.
-
(ADD DEBUG STATEMENTS) Normaly we would add breakpoints, but when remote debugging that's not always possible, because the files we need to put the breakpoints on aren't loaded yet by
jest
. So in order to make the debugger stop where we want it to, we need to adddebugger;
statements instead of breakpoints in the code and re-transpile if necessary. -
(ATTACH TO WEB SOCKET) Once we've started the tests in debug mode, we need to attach to it:
-
(RECOMMENDED) use chrome remote debug for node:
- open
chrome://inspect
in chrome address bar Open dedicated DevTools for Node
button- If you've started the tests with the aforementioned command it should automatically connect, but if it doesn't go to the
Connection
tab of the pop-up window and add connectionlocalhost:9229
or whatever your port is - The debugger should stop on the first line because of the
--inspect-brk
flag and once you press the play button (resume execution) it should stop on yourdebugger;
statement
NOTE: once it stops you may see all of your code is bundled up in one line. There's an easy fix for that: at the bottom of the debug window near the
Line: 1 Column: 1
labels you should see a{}
button that will prettify your code and you will still be able to debug properly. - open
-
(Use VSCode) Config should look close to this:
...
"configurations": [
{
"localRoot": "${workspaceFolder}/packages/provider", //change this depending on what test you're debugging
"remoteRoot": "${workspaceFolder}/packages/provider", //change this depending on what test you're debugging
"type": "node",
"request": "attach",
"name": "Attach to Server on 9229",
"address": "127.0.0.1",
"port": 9229
}
]
See the CONTRIBUTING.md for an extensive breakdown of the project
yarn commit
will commit files (same as git commit
), and will aid the
contributor with adding a suitable commit message inline with
conventional changelog