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
feat: Automatic TypeScript helper transpilation and arrow function parameter parsing
**TypeScript Helper Auto-Transpilation:**
- Added automatic transpilation of .ts helper files using TypeScript compiler
- Detects ERR_UNKNOWN_FILE_EXTENSION and transpiles to temporary .mjs files
- Cleans up temporary files after import
- No NODE_OPTIONS or ESM loaders needed - just install typescript
- Handles CommonJS interop issues with fallback transform
**Arrow Function Parameter Parsing:**
- Fixed parser to handle arrow functions: ({ I }) => {...}
- Added regex to convert arrow functions to regular functions for parsing
- Handles both async arrow functions and regular arrow functions
- Fixes parameter injection for modern JavaScript/TypeScript syntax
**Async Helper Loading Fix:**
- Fixed race condition where _init() was called before async helpers resolved
- Added await asyncHelperPromise before calling _init() on helpers
- Ensures all helpers are fully loaded before container.started() completes
**Documentation Updates:**
- Updated docs/typescript.md with automatic transpilation info
- Added explanation of why test files use tsx/cjs vs auto-transpilation
- Added TypeScript Files Support Matrix showing what's auto-transpiled
- Added troubleshooting section for common issues
- Clarified hybrid approach design decision
**Test Coverage:**
- Added test/data/typescript-helper-autoload/ with working TypeScript helper
- Test passes without NODE_OPTIONS, confirming automatic transpilation works
- Helper extends @codeceptjs/helper and methods are properly injected into I object
Bump version to 4.0.0-beta.21
Test files use a **loader** (`tsx/cjs`) while helpers use **auto-transpilation**. This hybrid approach is optimal because:
306
+
307
+
1.**Test files are loaded by Mocha** via `require()` - CodeceptJS can't intercept this, so we need a loader like `tsx/cjs` that hooks into Node.js's require system
308
+
2.**Helpers are loaded by CodeceptJS** via `import()` - we can catch the error and transpile on-demand
309
+
3.**Performance** - tsx's optimized loader with caching is faster for many test files
310
+
4.**Simplicity** - Auto-transpilation for helpers means no extra configuration needed
311
+
312
+
This gives you the best of both worlds: efficient test loading and zero-config helper transpilation!
313
+
314
+
#### Troubleshooting
315
+
316
+
**Error: "TypeScript helper detected but could not be loaded"**
0 commit comments