Skip to content

Commit 4b5444b

Browse files
feat: add TypeScript Express test bundle and TS-specific tests
Add node-ts-express test fixture with TypeScript entry point (app.ts) and @types/express devDependency. Add TestNodeJSTypeScriptBundle tests covering TS manifest structure, bundle contents, entry point detection, and devDependencies exclusion from packages section.
1 parent 6a75979 commit 4b5444b

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

tests/test_bundle.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,6 +3025,7 @@ def test_make_bundle_missing_file_in_manifest():
30253025
# -- Node.js bundle and manifest tests --
30263026

30273027
_NODE_EXPRESS_DIR = join(dirname(__file__), "testdata", "node-express")
3028+
_NODE_TS_EXPRESS_DIR = join(dirname(__file__), "testdata", "node-ts-express")
30283029

30293030

30303031
def _make_node_env(**overrides):
@@ -3202,3 +3203,43 @@ def test_validate_nonexistent_file(self):
32023203
def test_validate_auto_detection(self):
32033204
ep = validate_node_entry_point(None, _NODE_EXPRESS_DIR)
32043205
assert ep == "app.js"
3206+
3207+
3208+
class TestNodeJSTypeScriptBundle:
3209+
"""Tests for TypeScript Express bundles (Node.js 24+ native type stripping)."""
3210+
3211+
def test_ts_manifest_structure(self):
3212+
env = _make_node_env(node_version="24.14.0")
3213+
manifest, files = make_nodejs_manifest(_NODE_TS_EXPRESS_DIR, "app.ts", env, [], [])
3214+
3215+
assert manifest["metadata"]["appmode"] == "node-api"
3216+
assert manifest["metadata"]["entrypoint"] == "app.ts"
3217+
assert manifest["node"]["version"] == "24.14.0"
3218+
3219+
def test_ts_manifest_files(self):
3220+
env = _make_node_env(node_version="24.14.0")
3221+
manifest, files = make_nodejs_manifest(_NODE_TS_EXPRESS_DIR, "app.ts", env, [], [])
3222+
3223+
assert "app.ts" in manifest["files"]
3224+
assert "package.json" in manifest["files"]
3225+
3226+
def test_ts_bundle_contents(self):
3227+
env = _make_node_env(node_version="24.14.0")
3228+
bundle_file = make_nodejs_bundle(_NODE_TS_EXPRESS_DIR, "app.ts", env, [], [])
3229+
3230+
with tarfile.open(mode="r:gz", fileobj=bundle_file) as tar:
3231+
names = sorted(tar.getnames())
3232+
assert "manifest.json" in names
3233+
assert "app.ts" in names
3234+
assert "package.json" in names
3235+
3236+
def test_ts_entrypoint_detection(self):
3237+
ep = get_default_node_entrypoint(_NODE_TS_EXPRESS_DIR)
3238+
assert ep == "app.ts"
3239+
3240+
def test_ts_devdependencies_excluded(self):
3241+
env = _make_node_env(node_version="24.14.0")
3242+
manifest, _ = make_nodejs_manifest(_NODE_TS_EXPRESS_DIR, "app.ts", env, [], [])
3243+
3244+
# devDependencies (@types/express) should not be in packages
3245+
assert "@types/express" not in manifest.get("packages", {})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import express, { Request, Response } from 'express';
2+
3+
const app = express();
4+
const PORT = process.env.PORT || 3000;
5+
6+
app.get('/', (req: Request, res: Response) => {
7+
res.json({ status: 'ok', framework: 'express', language: 'typescript' });
8+
});
9+
10+
app.get('/health', (req: Request, res: Response) => {
11+
res.status(200).send('OK');
12+
});
13+
14+
app.listen(PORT, () => {
15+
console.log(`TypeScript Express server listening on port ${PORT}`);
16+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "node-ts-express",
3+
"version": "1.0.0",
4+
"description": "TypeScript Express HTTP server for testing",
5+
"main": "app.ts",
6+
"scripts": {
7+
"start": "node app.ts"
8+
},
9+
"dependencies": {
10+
"express": "^4.21.0"
11+
},
12+
"devDependencies": {
13+
"@types/express": "^4.17.21"
14+
}
15+
}

0 commit comments

Comments
 (0)