You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-3Lines changed: 31 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,10 @@ The file structure for each component should look like the following:
54
54
-`MyComponent.css`
55
55
-`MyComponent.test.tsx`
56
56
57
+
### TypeScript and JSX
58
+
59
+
This repo is configured to use TypeScript and JSX. Any file that uses TypeScript and JSX syntax (i.e. component files and any other files that include components) should use the `.tsx` extension.
60
+
57
61
### Testing Components During Development
58
62
59
63
To see how your component looks and behaves while you are developing it, you have a few different options. When you start the app locally, the main entry point that determines what is rendered is in `src/app.tsx`. Because this is a component library and not a fully integrated app, the `app.tsx` file exists solely as a testing sandbox. A simple routing structure has been setup to test out different kinds of pages in a react-only environment. These test pages live in the `src/pages` directory. When testing a new component, you can use it inside of one of the existing pages or you can create a new page. There is also the `Sandbox` page within the `pages` directory that is intended to be cleared out any time and used to test new discrete components.
@@ -66,9 +70,9 @@ By convention, almost all components are given a top-level class which is the na
66
70
67
71
The components in this library are intended to be used with the Bulma CSS Framework. For that reason, many bulma classes and component patterns are utilized within the components.
68
72
69
-
### Test ID's
73
+
### Test IDs
70
74
71
-
Also by convention, almost all components are given a "test id" via the attribute `data-testid`. In some cases, a component may have multiple elements with test id's. These id's make it easier to select the components and their testable parts within the unit tests.
75
+
Also by convention, almost all components are given a test ID via the attribute `data-testid`. In some cases, a component may have multiple elements with test IDs. These IDs make it easier to select the components and their testable parts within the unit tests.
72
76
73
77
### Component Utils
74
78
@@ -86,6 +90,28 @@ Most components also have their own props interface defined. Note that this inte
86
90
87
91
Any component that you want to be usable when this library is imported as a third-party node module must be added to the exports list in `src/index.ts`.
88
92
93
+
## Unit Tests
94
+
95
+
This repo uses [jest](https://jestjs.io/) and [react testing library](https://testing-library.com/) to write and run unit tests. Any file in the `src` directory with the `.test.tsx` or `.spec.tsx` extension will be detected as a runnable test.
96
+
97
+
Run all the unit tests:
98
+
99
+
```
100
+
npm run test
101
+
```
102
+
103
+
Run a specific test suite:
104
+
105
+
```
106
+
npm run test MaterialsInput
107
+
```
108
+
109
+
The jest configuration can be found in `jest.config.js`
110
+
111
+
### Mocks
112
+
113
+
To test the fetching behavior of the `SearchUI` components, there is a `mocks` directory which sets up a Mock Service Worker using the `msw` package. See more [here](https://mswjs.io/docs/getting-started/integrate/node).
114
+
89
115
## Deploying to npm
90
116
91
117
### Automated Pre-releases
@@ -104,7 +130,7 @@ Use `npm publish` to push to npm
104
130
105
131
### Automated Minor Release (un-tested)
106
132
107
-
Run `npm version minor -m "Upgrade to %s"` to add a tag. Once the tag is pushed, an action will
133
+
Run `npm version minor -m "Upgrade to %s"` to add a tag. Once the tag is pushed, an action willg
108
134
build the components and push the package to build to npm
109
135
110
136
## Developing with dash-mp-components
@@ -147,3 +173,5 @@ npm deploy-storybook
147
173
```
148
174
149
175
### Build Tools
176
+
177
+
This repo uses Parcel to build and run the app locally and Rollup to publish the app. Parcel does not have a config file, but it does use Babel to transpile the code for this repo. The babel configuration exists in `.babelrc` and `babel.config.js`. The Rollup configuration is defined in `rollup.config.js`.
0 commit comments