Test second format (#7565)
This commit is contained in:
1 parent
12d0be9874
commit
71b2d35d59
4 files changed
+64
-6
No files matched your search
+3
-1
@@ -12,7 +12,9 @@ Here's what you need to know about the tests:
|
||||
|
||||
- The tests use [Jest snapshots](https://facebook.github.io/jest/docs/en/snapshot-testing.html).
|
||||
- You can make changes and run `jest -u` (or `yarn test -u`) to update the snapshots. Then run `git diff` to take a look at what changed. Always update the snapshots when opening a PR.
|
||||
- You can run `AST_COMPARE=1 jest` for a more robust test run. That formats each file, re-parses it, and compares the new AST with the original one and makes sure they are semantically equivalent.
|
||||
- You can run `AST_COMPARE=1 DEEP_COMPARE=1 jest` for a more robust test run.
|
||||
- `AST_COMPARE` That formats each file, re-parses it, and compares the new AST with the original one and makes sure they are semantically equivalent.
|
||||
- `DEEP_COMPARE` That formats each file, then formats the output again, and checks that the second output is the same as the first.
|
||||
- Each test folder has a `jsfmt.spec.js` that runs the tests. For JavaScript files, generally you can just put `run_spec(__dirname, ["babel", "flow", "typescript"]);` there. This will verify that the output using each parser is the same. You can also pass options as the third argument, like this: `run_spec(__dirname, ["babel"], { trailingComma: "es5" });`
|
||||
- `tests/flow/` contains the Flow test suite, and is not supposed to be edited by hand. To update it, clone the Flow repo next to the Prettier repo and run: `node scripts/sync-flow-tests.js ../flow/tests/`.
|
||||
- If you would like to debug prettier locally, you can either debug it in node or the browser. The easiest way to debug it in the browser is to run the interactive `docs` REPL locally. The easiest way to debug it in node, is to create a local test file with some example code you want formatted and either run it in an editor like VS Code or run it directly via `./bin/prettier.js <your_test_file>`.
|
||||
|
||||
Reference in new issue
Block a user