Skip to content

Commit a45a40c

Browse files
Merge pull request #83 from SAP/timePicker-unit-test
added unit test and coverage for TimePicker
2 parents 3f50c65 + 1087d79 commit a45a40c

File tree

8 files changed

+2292
-138
lines changed

8 files changed

+2292
-138
lines changed

UNIT-TESTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@ Launches the test runner and display code coverage report as well starts interac
3232
Depending on the component, there are different approaches to creating unit tests. The easiest way to make sure that a component is rendered with the desired output is by creating a [snapshot](https://jestjs.io/docs/en/tutorial-react#snapshot-testing). The first time a snapshot is created it will render the component based off the prop values sent to the component. Each subsequent unit test will check against the snapshot to make sure the component is rendering exactly as before.
3333

3434
Testing user interaction of a component can be done with Enzyme and Jest. Please refer to [Enzyme's documentation](https://github.com/airbnb/enzyme#basic-usage) on how to interact with the DOM.
35+
36+
## Viewing results
37+
38+
You can view a nice visual representation of the code coverage status as well as see what lines are missing coverage. In the repository of your fundamental-react project navigate to <directory of fundamental-react>/coverage/lcov-report/index.html. From here you can click on the component name you want to view coverage for view the lines covered in the JS file. Placing your mouse over a highlighted line of code will display a tooltip.
39+
40+
## Common issues
41+
42+
### Invariant Violation: Target container is not a DOM element.
43+
44+
This issue is usually caused because the modules being imported are not properly defined. An example of improperly defining modules to be imported is by grouping all the components needed and just referencing the whole library.
45+
46+
Ex: `import {Popover, Time} from '../';`
47+
48+
The correct solution is to import the modules from their defined location.
49+
<br/><br/>
50+
Ex: `import {Popover} from '../Popover/Popover'; import {Time} from '../Time/Time';`

0 commit comments

Comments
 (0)