File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
test/data/typescript-tsx-esm Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ # TypeScript tsx ESM Test
2+
3+ This test demonstrates the recommended way to use TypeScript with CodeceptJS 4.x when you have ` "type": "module" ` in your package.json.
4+
5+ ## Key Features
6+
7+ - Uses ` tsx/cjs ` as the TypeScript loader (recommended over ts-node/esm)
8+ - Has ` "type": "module" ` in package.json
9+ - Imports page objects without file extensions
10+ - Everything works seamlessly
11+
12+ ## Configuration
13+
14+ - ** Loader** : ` tsx/cjs ` in ` require ` array
15+ - ** Package type** : ` "module" `
16+ - ** TypeScript module** : ` "esnext" ` with ` "node" ` module resolution
17+ - ** Imports** : No file extensions needed (tsx handles resolution)
18+
19+ ## Why tsx?
20+
21+ tsx is the recommended TypeScript loader for CodeceptJS 4.x because:
22+ - ✅ Works with ` "type": "module" `
23+ - ✅ Handles extensionless imports
24+ - ✅ Fast (built on esbuild)
25+ - ✅ Zero config needed
26+ - ✅ Compatible with Mocha's loading system
27+
28+ ## Why Not ts-node/esm?
29+
30+ ts-node/esm has significant limitations:
31+ - ❌ Doesn't work with ` "type": "module" `
32+ - ❌ Doesn't resolve extensionless imports to .ts files
33+ - ❌ Requires complex configuration
34+ - ❌ Module resolution doesn't work like standard TypeScript ESM
35+
36+ ## Running This Test
37+
38+ ``` bash
39+ cd test/data/typescript-tsx-esm
40+ ../../../bin/codecept.js run --verbose
41+ ```
42+
43+ You should see both scenarios pass successfully.
You can’t perform that action at this time.
0 commit comments