Commit 904d78c
authored
Fix tests (#205)
* fix(test): destroyOutput regeneration double serialization and output file mutation
Problem:
When running with destroyOutput set the following problems arise:
1. test/test.js called writeFile(outputFilename, result, options) where result is already
a serialized string returned by run(), effectivelly double encoding it.
The next test run (`npx jest test/test.js`) would load this corrupted content as the
expected snapshot, causing all JSON test cases in test.js to fail.
2. test/__utils__/test-utils.js loadTest() ran the CLI without overriding --output, so the
CLI used the output path from options.yaml. Which during a run with
`deleteOutput` set, would silently overwrite and mask
the corruption from (1) while still producing test failures.
Solution:
- Write the already-serialized result string directly with `fs.writeFileSync` in test.js.
- Pass --output <tmpfile> in loadTest so the CLI writes to a temp file instead of the
shared `output`. Output file mutation is now exclusive owned by `test.js`.
* fix(test): normalize no-sort/no-bundle option handling in test runner
Problem:
1. sort and bundle were unconditionally derived from no-sort/no-bundle,
ignoring explicit sort/bundle values set directly in options.yaml
2. The no-bundle delete guard incorrectly checked no-sort as its first
condition.
Solution:
Default sort and bundle to true, and only translate the no-X keys when they
are actually present in the options file.1 parent 10f68cb commit 904d78c
9 files changed
Lines changed: 14 additions & 16 deletions
File tree
- test
- __utils__
- json-default-bug-big-numbers
- json-delete-method
- json-filter-inverse-operationids-126
- json-filter-unused
- overlay-extends-local
- overlay-extends-remote
- yaml-filter-inverse-flagsvalue-value-array
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
| 131 | + | |
133 | 132 | | |
134 | 133 | | |
135 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
0 commit comments