Skip to content

Commit b17fee2

Browse files
committed
Improve build tool to adapt the new tests architecture
1 parent 2755ce8 commit b17fee2

File tree

8 files changed

+167
-1912
lines changed

8 files changed

+167
-1912
lines changed

.config/dotnet-tools.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
"fable"
99
]
1010
},
11-
"fantomas": {
12-
"version": "6.3.0-alpha-007",
13-
"commands": [
14-
"fantomas"
15-
]
16-
},
1711
"husky": {
1812
"version": "0.6.4",
1913
"commands": [
@@ -25,6 +19,12 @@
2519
"commands": [
2620
"femto"
2721
]
22+
},
23+
"fantomas": {
24+
"version": "6.3.0-beta-001",
25+
"commands": [
26+
"fantomas"
27+
]
2828
}
2929
}
3030
}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,5 @@ src/Glutinum.Web/CssModules.fs
346346
*.fable-temp.csproj
347347

348348
.DS_Store
349+
350+
tests/specs/generated/

README.md

+59-4
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,69 @@ type FSharpAttribute =
7373

7474
### Tests
7575

76-
Tests are generated based on the `tests/specs/` folder content.
76+
This project use [Vitest](https://vitest.dev/) for running tests.
7777

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.
7979

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.
8181

82-
The name of the test is `exports/variable`.
82+
#### VSCode
8383

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]
84139
> If you are using VSCode, the `fsx` file will be nested under the `d.ts` file in your explorer.
85140
86141
The `.fsx` correspond to the expected result suffixed with the following:

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"@ts-morph/bootstrap": "^0.22.0",
3535
"@vitejs/plugin-react": "^4.2.1",
3636
"@vitest/ui": "^1.3.1",
37-
"ava": "^6.1.2",
3837
"bulma": "^0.9.4",
3938
"dirname-filename-esm": "^1.1.1",
4039
"fable-css-modules": "^1.7.0",

0 commit comments

Comments
 (0)