Skip to content

Commit aa51d1d

Browse files
committed
readmes for testing
1 parent 18070a0 commit aa51d1d

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ When you want to test the component within a solid-pane, you can use the [develo
7070

7171
## Adding Tests
7272

73-
Need to point to Unit test Readme.
73+
The following document gives guidance on how to add and perform testing in solid-ui.
74+
[Testing in solid-ui](https://github.com/SolidOS/solid-ui/blob/18070a02fa8159a2b83d9503ee400f8e046bf1f6/test/unit/README.md)
7475

7576
## Further documentation
7677

test/unit/README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
# Solid-UI Unit Testing
2-
2+
The purpose of this README is to provide guidance on how to write tests for solid-ui for beginners.
33

44
## Running Tests
55

6+
### All
7+
The following command will run all the tests.
8+
`npm run test`
9+
### One file at a time
10+
There are a lot of tests in `solid-ui` so you will most likely want to run only the test you are working on at the moment. In order to do that you can use the following command.
11+
`npm test <filetobetested>`
12+
`npm test test/unit/utils/keyHelpers/accessData.test.ts`
613

714
## Tips and Tricks
15+
The following are some tips and tricks in hopes to make testing easier.
16+
17+
### VSCode debugging
18+
19+
### Mocking
20+
In solid-ui we do not currently follow a MVC pattern therefore there can be some difficulty in testing. The following are patterns to help with this.
21+
#### Store methods
22+
##### Load
23+
In SolidOS we use [rdflib.js](https://github.com/linkeddata/rdflib.js/) to work with LinkedData. The way this works is that you first load the document you need to work with into the store. Once the document is loaded you can then access the data by using additional methods on the store such as `any, each,...`. Since the data that gets returned will need to be mocked, `load` doesn't need to do anything. See below for what you need to put in the top of your file in order to mock the `load` method.
24+
`import { store } from 'solid-logic'` at the top of your file.
25+
26+
`store.fetcher.load = jest.fn().mockImplementation(() => {})`
827

9-
### Mock the fetcher
28+
##### Any
1029

30+
##### Each

0 commit comments

Comments
 (0)