Refactor tests (#18743)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
ef46101aa6
commit
ed5bb0bf62
288 files changed
+730
-753
No files matched your search
+26
-4
@@ -45,11 +45,33 @@ function runFormatTest(
|
||||
): void;
|
||||
```
|
||||
|
||||
Parameters:
|
||||
### **`fixtures`**
|
||||
|
||||
- **`fixtures`**: Must be set to `import.meta` or to an object of the shape `{ importMeta: import.meta, ... }`. The object may have the `snippets` property to specify an array of extra input entries in addition to the files in the current directory. For each input entry (a file or a snippet), `runFormatTest` configures and runs a number of tests. The main check is that for a given input the output should match the snapshot (for snippets, the expected output can also be specified directly). [Additional checks](#deeper-testing) are controlled by options and environment variables.
|
||||
- **`parsers`**: A list of parser names. The tests verify that the parsers in this list produce the same output. If the list includes `typescript`, then `babel-ts`, and `oxc-ts` are included implicitly. If the list includes `flow`, then `hermes` is included implicitly. If the list includes `babel`, and the current directory is inside `tests/format/js` or `tests/format/jsx`, then `acorn`, `espree`, `meriyah`, and `oxc` are included implicitly.
|
||||
- **`options`**: In addition to Prettier's formatting options, can contain the `errors` property to specify that it's expected that the formatting shouldn't be successful and an error should be thrown for all (`errors: true`) or some combinations of input entries and parsers.
|
||||
Must be set to `import.meta` or to an object of the shape `{ importMeta: import.meta, ... }`.
|
||||
|
||||
The object may have the `snippets` property to specify an array of extra input entries in addition to the files in the current directory.
|
||||
|
||||
For each input entry (a file or a snippet), `runFormatTest` configures and runs a number of tests.
|
||||
|
||||
The main check is that for a given input the output should match the snapshot (for snippets, the expected output can also be specified directly).
|
||||
|
||||
[Additional checks](#deeper-testing) are controlled by options and environment variables.
|
||||
|
||||
### **`parsers`**
|
||||
|
||||
A list of parser names.
|
||||
|
||||
The tests verify that the parsers in this list produce the same output.
|
||||
|
||||
If the list includes `typescript`, then `babel-ts`, and `oxc-ts` are included implicitly.
|
||||
|
||||
If the list includes `flow`, then `hermes` is included implicitly.
|
||||
|
||||
If the list includes `babel`, and the current directory is inside `tests/format/js` or `tests/format/jsx`, then `acorn`, `espree`, `meriyah`, and `oxc` are included implicitly.
|
||||
|
||||
### **`options`**
|
||||
|
||||
In addition to Prettier's formatting options, can contain the `errors` property to specify that it's expected that the formatting shouldn't be successful and an error should be thrown for all (`errors: true`) or some combinations of input entries and parsers.
|
||||
|
||||
The implementation of `runFormatTest` can be found in [`tests/config/run-format-test.js`](tests/config/run-format-test.js).
|
||||
|
||||
|
||||
Reference in new issue
Block a user