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
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -331,9 +331,40 @@ Please use GitHub's Issues/PRs.
331
331
332
332
### Development Tools
333
333
334
-
-`yarn test` runs tests and measures coverage.
334
+
-`yarn test` runs tests.
335
+
-`yarn cover` runs tests and measures coverage.
335
336
-`yarn update` runs in order to update readme and recommended configuration.
336
337
338
+
### Test the Rule
339
+
340
+
Rule testing almost always uses fixtures.
341
+
For example, for an `indent` rule, the `.ts` file that runs the test is `tests/src/rules/indent.ts` and the fixture is in `tests/fixtures/rules/indent`.
342
+
The fixture directory has an `invalid` directory and a `valid` directory.
343
+
344
+
- The `invalid` directory contains test cases where the rule reports problems.
345
+
- The `valid` directory contains test cases where the rule does not report a problem.
346
+
347
+
The fixture input file should be named `*-input.svelte`. It is automatically collected and tested.
348
+
If your test requires configuration, you need to add a json file with the configuration.
349
+
350
+
- If you want to apply a configuration to `my-test-input.svelte`, add `my-test-config.json`.
351
+
- If you want to apply the same configuration to all the fixtures in that directory, add `_config.json`.
352
+
353
+
To verify the output of invalid test cases requires `*-errors.json`, and `*-output.svelte` (for auto-fix). However, you don't have to add them yourself. If they do not exist, they will be automatically generated when you run the test. In other words, delete them manually when you want to recreate them.
354
+
355
+
**Tips**:
356
+
357
+
If you want to test only one rule, run the following command (for `indent` rule):
358
+
359
+
```sh
360
+
yarn test -g indent
361
+
```
362
+
363
+
Take https://stackoverflow.com/questions/10832031/how-to-run-a-single-test-with-mocha as reference for details.
364
+
365
+
If you want to test only `my-test-input.svelte`, add `my-test-config.json` and save `{"only": true}`.
366
+
(Note that `{"only": true}` must be removed before making a pull request.)
367
+
337
368
### Working With Rules
338
369
339
370
This plugin uses [svelte-eslint-parser](https://github.com/ota-meshi/svelte-eslint-parser) for the parser. Check [here](https://ota-meshi.github.io/svelte-eslint-parser/) to find out about AST.
0 commit comments