|
| 1 | +## 🧪 Debugging Skipped Transformer Tests |
| 2 | + |
| 3 | +Welcome! This guide will walk you through the process of solving skipped transformer test cases. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +### ✅ Setup Instructions |
| 8 | + |
| 9 | +1. **Clear your working directory** |
| 10 | + |
| 11 | +2. **Checkout the main branch**: |
| 12 | + |
| 13 | + ```bash |
| 14 | + git checkout main |
| 15 | + git pull origin main |
| 16 | + ``` |
| 17 | + |
| 18 | +3. **Create a new branch from \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*`main`**: |
| 19 | + *⚠️ Do not commit directly to **************`main`**************.* |
| 20 | + |
| 21 | + ```bash |
| 22 | + git checkout -b fix/<your-branch-name> |
| 23 | + ``` |
| 24 | + |
| 25 | +4. **Install dependencies and build the project**: |
| 26 | + |
| 27 | + ```bash |
| 28 | + yarn |
| 29 | + yarn build |
| 30 | + ``` |
| 31 | + |
| 32 | +5. **Navigate to the transform package and run tests**: |
| 33 | + |
| 34 | + ```bash |
| 35 | + cd packages/transform |
| 36 | + yarn test |
| 37 | + ``` |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +### 🔍 Where to Find Issues |
| 42 | + |
| 43 | +Skipped tests (i.e. known transformer issues) are tracked in: |
| 44 | + |
| 45 | +``` |
| 46 | +packages/transform/test-utils/skip-tests/transformer-errors.ts |
| 47 | +``` |
| 48 | + |
| 49 | +Each entry looks like this: |
| 50 | + |
| 51 | +```ts |
| 52 | +[16, 17, "pretty/misc-5.sql", "16-17 transformer fails WITH clause TypeCast prefix issue: transformer adds pg_catalog prefix to JSON types when expected output has none"] |
| 53 | +``` |
| 54 | + |
| 55 | +* `16, 17` refers to Postgres versions (previous->next) where this issue occurs. |
| 56 | +* `pretty/misc-5.sql` is the test case. |
| 57 | +* The last string is a human-readable explanation of the problem. |
| 58 | + |
| 59 | +You can run an individual test like this: |
| 60 | + |
| 61 | +```bash |
| 62 | +yarn test __tests__/kitchen-sink/16-17/pretty-misc.test.ts |
| 63 | +``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +### 🛠 Fixing the Test |
| 68 | + |
| 69 | +1. Reproduce the failure with the specific test file above. |
| 70 | +2. Once fixed, **comment out** the corresponding line in `transformer-errors.ts`. |
| 71 | +3. Re-run the test to confirm it now passes: |
| 72 | + |
| 73 | +```bash |
| 74 | +yarn test __tests__/kitchen-sink/16-17/pretty-misc.test.ts |
| 75 | +``` |
| 76 | + |
| 77 | +Then, commit your fix and open a pull request. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +### 🧾 Test Fixture Naming Convention |
| 82 | + |
| 83 | +Test files like: |
| 84 | + |
| 85 | +``` |
| 86 | +__tests__/kitchen-sink/16-17/pretty/misc-6.sql |
| 87 | +``` |
| 88 | + |
| 89 | +Follow a specific naming pattern: |
| 90 | + |
| 91 | +* `pretty/` is the folder of test fixture dir (e.g. pretty-printing). |
| 92 | +* `misc-6.sql` means it's the **6th SQL statement** from the original `misc.sql` test file. |
| 93 | +* \_\_fixtures\_\_/kitchen-sink/ is where the original sql lives, if you need to see it, in this case \_\_fixtures\_\_/kitchen-sink/pretty is the folder, and \_\_fixtures\_\_/kitchen-sink/pretty/misc.sql is the file |
| 94 | + |
| 95 | +#### Why this format? |
| 96 | + |
| 97 | +We split multi-statement fixture files into **line-by-line test cases** to: |
| 98 | + |
| 99 | +* Improve test isolation and debugging clarity |
| 100 | +* Enable precise diffs |
| 101 | +* Optimize performance by bundling all SQL files into a **single JSON blob** during test runs |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +Ready to contribute? Pick an issue from `transformer-errors.ts`, debug, and push a clean fix on your branch! |
| 106 | + |
| 107 | +Let’s squash these transformer bugs one at a time 💥 |
0 commit comments