|
| 1 | +--- |
| 2 | +name: run-e2e-tests |
| 3 | +description: Run E2E tests to verify complete user workflows like environment discovery, creation, and selection. Use this before releases or after major changes. |
| 4 | +--- |
| 5 | + |
| 6 | +Run E2E (end-to-end) tests to verify complete user workflows work correctly. |
| 7 | + |
| 8 | +## When to Use This Skill |
| 9 | + |
| 10 | +- Before submitting a PR with significant changes |
| 11 | +- After modifying environment discovery, creation, or selection logic |
| 12 | +- Before a release to validate full workflows |
| 13 | +- When user reports a workflow is broken |
| 14 | + |
| 15 | +**Note:** Run smoke tests first. If smoke tests fail, E2E tests will also fail. |
| 16 | + |
| 17 | +## Quick Reference |
| 18 | + |
| 19 | +| Action | Command | |
| 20 | +| ----------------- | -------------------------------------------------------------- | |
| 21 | +| Run all E2E tests | `npm run compile && npm run compile-tests && npm run e2e-test` | |
| 22 | +| Run specific test | `npm run e2e-test -- --grep "discovers"` | |
| 23 | +| Debug in VS Code | Debug panel → "E2E Tests" → F5 | |
| 24 | + |
| 25 | +## How E2E Tests Work |
| 26 | + |
| 27 | +Unlike unit tests (mocked) and smoke tests (quick checks), E2E tests: |
| 28 | + |
| 29 | +1. Launch a real VS Code instance with the extension |
| 30 | +2. Exercise complete user workflows via the real API |
| 31 | +3. Verify end-to-end behavior (discovery → selection → execution) |
| 32 | + |
| 33 | +They take longer (1-3 minutes) but catch integration issues. |
| 34 | + |
| 35 | +## Workflow |
| 36 | + |
| 37 | +### Step 1: Compile and Run |
| 38 | + |
| 39 | +```bash |
| 40 | +npm run compile && npm run compile-tests && npm run e2e-test |
| 41 | +``` |
| 42 | + |
| 43 | +### Step 2: Interpret Results |
| 44 | + |
| 45 | +**Pass:** |
| 46 | + |
| 47 | +``` |
| 48 | + E2E: Environment Discovery |
| 49 | + ✓ Can trigger environment refresh |
| 50 | + ✓ Discovers at least one environment |
| 51 | + ✓ Environments have required properties |
| 52 | + ✓ Can get global environments |
| 53 | +
|
| 54 | + 4 passing (45s) |
| 55 | +``` |
| 56 | + |
| 57 | +**Fail:** Check error message and see Debugging section. |
| 58 | + |
| 59 | +## Debugging Failures |
| 60 | + |
| 61 | +| Error | Cause | Fix | |
| 62 | +| ---------------------------- | ---------------------- | ------------------------------------------- | |
| 63 | +| `No environments discovered` | Python not installed | Install Python, verify it's on PATH | |
| 64 | +| `Extension not found` | Build failed | Run `npm run compile` | |
| 65 | +| `API not available` | Activation error | Debug with F5, check Debug Console | |
| 66 | +| `Timeout exceeded` | Slow operation or hang | Increase timeout or check for blocking code | |
| 67 | + |
| 68 | +For detailed debugging: Debug panel → "E2E Tests" → F5 |
| 69 | + |
| 70 | +## Prerequisites |
| 71 | + |
| 72 | +E2E tests have system requirements: |
| 73 | + |
| 74 | +- **Python installed** - At least one Python interpreter must be discoverable |
| 75 | +- **Extension builds** - Run `npm run compile` before tests |
| 76 | +- **CI needs webpack build** - Run `npm run compile` (webpack) before tests, not just `npm run compile-tests` (tsc) |
| 77 | + |
| 78 | +## Adding New E2E Tests |
| 79 | + |
| 80 | +Create files in `src/test/e2e/` with pattern `*.e2e.test.ts`: |
| 81 | + |
| 82 | +```typescript |
| 83 | +import * as assert from 'assert'; |
| 84 | +import * as vscode from 'vscode'; |
| 85 | +import { waitForCondition } from '../testUtils'; |
| 86 | +import { ENVS_EXTENSION_ID } from '../constants'; |
| 87 | + |
| 88 | +suite('E2E: [Workflow Name]', function () { |
| 89 | + this.timeout(120_000); // 2 minutes |
| 90 | + |
| 91 | + let api: ExtensionApi; |
| 92 | + |
| 93 | + suiteSetup(async function () { |
| 94 | + const extension = vscode.extensions.getExtension(ENVS_EXTENSION_ID); |
| 95 | + assert.ok(extension, 'Extension not found'); |
| 96 | + if (!extension.isActive) await extension.activate(); |
| 97 | + api = extension.exports; |
| 98 | + }); |
| 99 | + |
| 100 | + test('[Test description]', async function () { |
| 101 | + // Use real API (flat structure, not nested!) |
| 102 | + // api.getEnvironments(), not api.environments.getEnvironments() |
| 103 | + await waitForCondition( |
| 104 | + async () => (await api.getEnvironments('all')).length > 0, |
| 105 | + 60_000, |
| 106 | + 'No environments found', |
| 107 | + ); |
| 108 | + }); |
| 109 | +}); |
| 110 | +``` |
| 111 | + |
| 112 | +## Test Files |
| 113 | + |
| 114 | +| File | Purpose | |
| 115 | +| ----------------------------------------------- | ------------------------------------ | |
| 116 | +| `src/test/e2e/environmentDiscovery.e2e.test.ts` | Discovery workflow tests | |
| 117 | +| `src/test/e2e/index.ts` | Test runner entry point | |
| 118 | +| `src/test/testUtils.ts` | Utilities (`waitForCondition`, etc.) | |
| 119 | + |
| 120 | +## Notes |
| 121 | + |
| 122 | +- E2E tests are slower than smoke tests (expect 1-3 minutes) |
| 123 | +- They may create/modify files - cleanup happens in `suiteTeardown` |
| 124 | +- First run downloads VS Code (~100MB, cached in `.vscode-test/`) |
| 125 | +- For more details on E2E tests and how they compare to other test types, refer to the project's testing documentation. |
0 commit comments