This project uses the fork feature in Github for anyone outside of the core maintainers.
We use NVM to manage node versions. Our node version is in the ./nvmrc
file. We also assume you have access to our private org on NPM.
Run the following commands to get your local development environment set up.
- Make sure you're using the specified npm version
nvm use
- Install all dependencies off of the package-lock.json. (Use
npm i
if you're introducing new dependencies. Please note that all dev-dependencies need to be listed on the root package.json as well as the package specific package.json)
npm ci
- Builds all the things
npm run build
- We use Storybook to develop locally along with Next.js.
npm run storybook
- Don't forget to add your component to the kitchen-sink page. You can run
npm run docsite:dev
to develop and test with the kitchen-sink page. You can only access this page directly viahttp://localhost:3000/kitchen-sink
. This page allows us to quickly check that all the components render as expected.
We use Testing Library and/or Storybook's new Interaction feature for Unit & Interaction Testing
This command runs the Jest.
npm run test
This command runs the Storybook Test runner
npm run test-storybook
Good resources on testing:
- https://kentcdodds.com/blog/testing-implementation-details
- https://kentcdodds.com/blog/making-your-ui-tests-resilient-to-change
Avoid writing "render" or "display" tests. Leverage our "Tests" stories in Storybook for this. Those UI tests will be tested in Chromatic.
Create a new component use the following command. It will stub out all the required files using plop-templates.
npm run new-component NewComponentName
You can create an experimental release for testing by following the release doc
We will use the npx git-publish
CLI from git-publish to test a PR in your project. Along with GitPkg. This will allow you to test a PR in your project without having to wait for a release. This method will unlock the ability to test in Preview and Staging environments. We're looking into automating this as part of our PR CI.
# cd into the package directory for the component you want to test
cd ui/select
# run the git-publish command. it will prompt you to install if its your first time
npx git-publish
# it will publish the package to our repo under `npm/<your-branch-name>`
Then in your project you can run the following command to install the package from the branch.
npm install 'https://gitpkg.now.sh/washingtonpost/wpds-ui-kit/<component-directory>?<your-branch-name'
You may need to override the version of the package in your package.json. You can do this by adding the following to your package.json.
"overrides": {
"@washingtonpost/wpds-select": "https://gitpkg.now.sh/washingtonpost/wpds-ui-kit/select?main"
}
Or running npm dedupe
after installing the package.