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
+59-4
Original file line number
Diff line number
Diff line change
@@ -73,14 +73,69 @@ type FSharpAttribute =
73
73
74
74
### Tests
75
75
76
-
Tests are generated based on the `tests/specs/` folder content.
76
+
This project use [Vitest](https://vitest.dev/) for running tests.
77
77
78
-
Each `.d.ts` correspond to a test and should have a matching `.fsx` file, the name of the test is the relative path to the `tests/specs/` folder without the `.d.ts` extension.
78
+
Vitest was chosen because it seems to have a lot of attention and is actively maintained. Plus, it seems well integrated with VSCode and Rider, allowing us to use the test explorer and even debug the tests using source maps.
79
79
80
-
For example, if you have a file `tests/specs/exports/variable.d.ts`, you should have a `tests/specs/exports/variable.fsx`.
80
+
If you prefer, it is possible to run the tests via the CLI.
81
81
82
-
The name of the test is `exports/variable`.
82
+
#### VSCode
83
83
84
+
Install [Vitest plugin](https://marketplace.visualstudio.com/items?itemName=vitest.explorer), then you will be able to run the tests from the test explorer.
85
+
86
+
#### Rider
87
+
88
+
You need to add a new configuration of type `Vitest`.
89
+
90
+
1.`Run > Edit Configurations...`
91
+
2. Add a new configuration of type `Vitest`
92
+
3. Then you can run the tests by selecting the configuration in the top right corner of the IDE.
93
+
94
+
#### Specs
95
+
96
+
> [!TIP]
97
+
> Run `./build.sh --help` to see the available options (look for `test specs` command).
98
+
99
+
Specs tests are using to test isolated TypeScript syntax and their conversion to F#.
100
+
101
+
They are generated based on the `tests/specs/references` folder.
102
+
103
+
Each `.d.ts` correspond to a test and have a matching `.fsx` file.
104
+
105
+
When running `./build.sh test specs`, it will generate a similar hierarchy in the `tests/specs/generated` folder.
106
+
107
+
Example:
108
+
109
+
```text
110
+
tests/specs/references
111
+
├── interfaces
112
+
│ ├── callSignature.d.ts
113
+
│ ├── callSignature.fsx
114
+
│ └── indexSignature
115
+
│ ├── numberParameter.d.ts
116
+
│ └── numberParameter.fsx
117
+
└── typeQuery
118
+
├── class.d.ts
119
+
├── class.fsx
120
+
├── defaultToObj.d.ts
121
+
└── defaultToObj.fsx
122
+
```
123
+
124
+
generates:
125
+
126
+
```text
127
+
tests/specs/generated
128
+
├── interfaces
129
+
│ ├── index.test.js
130
+
│ └── indexSignature
131
+
│ └── index.test.js
132
+
└── typeQuery
133
+
└── index.test.js
134
+
```
135
+
136
+
`index.test.js` contains all the tests for the `.d.ts` of the same folder.
137
+
138
+
> [!NOTE]
84
139
> If you are using VSCode, the `fsx` file will be nested under the `d.ts` file in your explorer.
85
140
86
141
The `.fsx` correspond to the expected result suffixed with the following:
0 commit comments