cline/test-setup.js
Tomás Barreiro d162a4b420
Alias paths on integration tests (#3196)
* Run pretest in CI to build all tests

* Alias paths when running tests
2025-04-30 17:49:40 -07:00

23 lines
733 B
JavaScript

const tsConfigPaths = require("tsconfig-paths")
const fs = require("fs")
const tsConfig = JSON.parse(fs.readFileSync("./tsconfig.json", "utf-8"))
/**
* The aliases point towards the `src` directory.
* However, `tsc` doesn't compile paths by itself
* (https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths-does-not-affect-emit)
* So we need to use tsconfig-paths to resolve the aliases when running tests,
* but pointing to `out` instead.
*/
const outPaths = {}
Object.keys(tsConfig.compilerOptions.paths).forEach((key) => {
const value = tsConfig.compilerOptions.paths[key]
outPaths[key] = value.map((path) => path.replace("src", "out"))
})
tsConfigPaths.register({
baseUrl: ".",
paths: outPaths,
})