mirror of
https://github.com/cline/cline.git
synced 2025-06-03 03:59:07 +00:00
Alias paths on integration tests (#3196)
* Run pretest in CI to build all tests * Alias paths when running tests
This commit is contained in:
parent
1704684af8
commit
d162a4b420
@ -6,6 +6,10 @@ export default defineConfig({
|
||||
mocha: {
|
||||
ui: "bdd",
|
||||
timeout: 20000, // Maximum time (in ms) that a test can run before failing
|
||||
/** Set up alias path resolution during tests
|
||||
* @See {@link file://./test-setup.js}
|
||||
*/
|
||||
require: ["./test-setup.js"],
|
||||
},
|
||||
workspaceFolder: "test-workspace",
|
||||
version: "stable",
|
||||
|
22
test-setup.js
Normal file
22
test-setup.js
Normal file
@ -0,0 +1,22 @@
|
||||
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,
|
||||
})
|
Loading…
Reference in New Issue
Block a user