The answer, I've determined, is "You can't do this with lite-server". My alternative is to use Express, which provides an API to define routing rules that do exactly what I need. It's a little hacky (e.g., response.sendFile(...) doesn't support relative paths, hence the path.join(...)
quackery below), but I'll make it work.
My tests will be run against an instance of Node bootstrapping with a script like this one:
var express = require('express');
var debug = require('debug')('app');
var path = require('path');
var app = express();
app.use(express.static('.'));
app.get('/',
function (req, res) {
debug("Root URL requested.");
res.sendFile(path.join(__dirname, 'index.html'));
});
app.get('/test',
function (req, res) {
debug("GET on /test")
res.send('Hello World');
});
var port = process.env.PORT || 3000;
debug("Using port ", port);
var server = app.listen(port,
function() {
var host = server.address().address;
var port = server.address().port;
console.log('Listening at http://%s:%s', host, port);
});
}
I've updated package.json like so:
"main": "nodeapp.js",
"scripts": {
"cc": "concurrently \"npm -v\" \"npm run tsc:w\" ",
"start": "concurrently \"npm run tsc -v\" \"npm run tsc:w\" \"node nodeapp.js\" ",
...