Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A collection of reusable components used by The Times

License

NotificationsYou must be signed in to change notification settings

newsuk/times-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coverage StatusBuild Status

Purpose

Home of The Times'react components.

Dev Environment

We require MacOS withNode.js (for specific version please check package.json restrictions),yarn (latest)

You can try without these requirements, but you'd be on your own.

Viewing Our Components

Go tohttp://components.thetimes.co.uk

Getting Started

  1. Runyarn install

  2. Components can be seen running in a storybook

Schema

Seeutils package on how to update the schema.

Debugging

The components in this project can be debugged through your browser's developertools. These steps assume the use of Chrome DevTools.

To debug our web Storybook:

  1. yarn storybook
  2. navigate tohttp://localhost:9001
  3. open DevTools
  4. ClickSources
  5. In theNetwork tab under the leftmost pane, expandtop =>storybook-preview-iframe =>webpack:// =>. =>packages

Any of these source files can be debugged directly.

Link times-components to the Render project

Follow these stepshere

You will also see the option to do a canary release in the pipeline, which will publish a test version of your changes that you can import in render.

See your changes in Render with rnw.js files

Besides linking the Times Components and Render repos together, you can view changes made to Times Components in Render through the rnw.js files.

  1. In Times Components, after you have made your changes, runyarn bundle in the package in which you were working. If you were working in thets-components package you will need to runyarn build first and thenyarn bundle.
  2. Running the command creates an rnw.js file in the root of the folder. Check the file to see if your changes have come through.
  3. Copy the contents of the rnw.js file and paste it into the related file in Render'snode_modules. For example, if you bundled the rnw.js file in thearticle-skeleton package in Times Components, you would paste the contents intonode_modules/@times-components/article-skeleton/rnw.js.
  4. Run render and you should see your changes.

Debugging the tests

Tests are currently usingjest to run so if you want to debug any test follow these steps:

  1. (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.

  2. See your test command from thepackage.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 thenode_modules/.bin/jest

  1. (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 .

  1. (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 byjest. 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.

  2. (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:

    1. openchrome://inspect in chrome address bar
    2. Open dedicated DevTools for Node button
    3. If you've started the tests with the aforementioned command it should automatically connect, but if it doesn't go to theConnection tab of the pop-up window and add connectionlocalhost:9229 or whatever your port is
    4. 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 theLine: 1 Column: 1 labels you should see a{} button that will prettify your code and you will still be able to debug properly.

  • (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      }  ]

Contributing

See theCONTRIBUTING.md for an extensive breakdown ofthe project.

yarn commit will commit files (same asgit commit), and will aid thecontributor with adding a suitable commit message inline withconventional changelog


[8]ページ先頭

©2009-2025 Movatter.jp