You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test: add workspaceUtils utility and refactor test paths
- Introduced `workspaceUtils` for consistent workspace directory resolution
- Added unit tests for `findWorkspaceRoot`, `getScriptPath`, `getWorkspacePath`, and `setupTestPaths`
- Refactored CLI and script integration tests to utilize `workspaceUtils`
- Updated `nx.json` and `package.json` with explicit `test:unit` and `test:integration` targets for granular control
|**Affected**| ✅ Only changed | ✅ Only changed | ❌ | Development workflow |
199
+
|**CI**| ✅ | ✅ | ✅ | Production deployments |
200
+
201
+
### 🎪 **Examples of Correct Placement**
202
+
203
+
```typescript
204
+
// ✅ Unit Test - packages/theme/src/tests/components/
205
+
describe('VocabularyTable', () => {
206
+
it('renders headers correctly', () => {
207
+
// Tests pure component logic
208
+
});
209
+
});
210
+
211
+
// ✅ Integration Test - packages/theme/src/tests/scripts/
212
+
describe('Google Sheets API', () => {
213
+
it('fetches vocabulary data', async () => {
214
+
// Tests external API integration
215
+
});
216
+
});
217
+
218
+
// ✅ E2E Test - /e2e/
219
+
test('user can navigate between sites', async ({ page }) => {
220
+
// Tests full browser workflows
221
+
});
222
+
```
223
+
224
+
**Key principle**: Unit tests run fast in pre-commit for immediate feedback, integration tests run in comprehensive scenarios, E2E tests validate complete user experiences.
225
+
226
+
### 🛠️ **Test Utilities**
227
+
228
+
For consistent directory handling in tests, use the `workspaceUtils` helper:
**Always use `workspaceUtils` instead of `process.cwd()` in integration tests** to ensure consistent directory resolution regardless of test execution context.
244
+
150
245
### Content and Navigation Rules
151
246
-**Never hardcode URLs**: Always use SiteLink component or configuration-based URLs
0 commit comments