mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Add support for tests that use ESM libraries (#3172)
* Add support for tests that use ESM libraries * Disable win32 for this test for now
This commit is contained in:
parent
aceff7dfe8
commit
11ed7d7d46
6 changed files with 1073 additions and 17 deletions
4
.github/workflows/code-qa.yml
vendored
4
.github/workflows/code-qa.yml
vendored
|
|
@ -78,8 +78,10 @@ jobs:
|
|||
run: npm run install:all
|
||||
- name: Compile (to build and copy WASM files)
|
||||
run: npm run compile
|
||||
- name: Run unit tests
|
||||
- name: Run jest unit tests
|
||||
run: npx jest --silent
|
||||
- name: Run vitest unit tests
|
||||
run: npx vitest run --silent
|
||||
|
||||
test-webview:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
|
|
|||
1032
package-lock.json
generated
1032
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -337,8 +337,9 @@
|
|||
"package": "npm-run-all -l -p build:webview build:esbuild check-types lint",
|
||||
"pretest": "npm run compile",
|
||||
"dev": "cd webview-ui && npm run dev",
|
||||
"test": "node scripts/run-tests.js",
|
||||
"test": "npm-run-all test:*",
|
||||
"test:extension": "jest -w=40%",
|
||||
"test:extension-esm": "vitest run",
|
||||
"test:webview": "cd webview-ui && npm run test",
|
||||
"prepare": "husky",
|
||||
"publish:marketplace": "vsce publish && ovsx publish",
|
||||
|
|
@ -459,6 +460,7 @@
|
|||
"tsup": "^8.4.0",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^5.4.5",
|
||||
"vitest": "^3.1.2",
|
||||
"zod-to-ts": "^1.2.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
// run-tests.js
|
||||
const { execSync } = require("child_process")
|
||||
|
||||
if (process.platform === "win32") {
|
||||
execSync("npm-run-all test:*", { stdio: "inherit" })
|
||||
} else {
|
||||
execSync("npm-run-all -p test:*", { stdio: "inherit" })
|
||||
}
|
||||
35
src/integrations/terminal/__tests__/ExecaTerminal.spec.ts
Normal file
35
src/integrations/terminal/__tests__/ExecaTerminal.spec.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// npx vitest run src/integrations/terminal/__tests__/ExecaTerminal.spec.ts
|
||||
|
||||
import { vi, describe, it, expect } from "vitest"
|
||||
|
||||
import { RooTerminalCallbacks } from "../types"
|
||||
import { ExecaTerminal } from "../ExecaTerminal"
|
||||
|
||||
describe("ExecaTerminal", () => {
|
||||
it("should run terminal commands and collect output", async () => {
|
||||
// TODO: Run the equivalent test for Windows.
|
||||
if (process.platform === "win32") {
|
||||
return
|
||||
}
|
||||
|
||||
const terminal = new ExecaTerminal(1, "/tmp")
|
||||
let result
|
||||
|
||||
const callbacks: RooTerminalCallbacks = {
|
||||
onLine: vi.fn(),
|
||||
onCompleted: (output) => (result = output),
|
||||
onShellExecutionStarted: vi.fn(),
|
||||
onShellExecutionComplete: vi.fn(),
|
||||
}
|
||||
|
||||
const subprocess = terminal.runCommand("ls -al", callbacks)
|
||||
await subprocess
|
||||
|
||||
expect(callbacks.onLine).toHaveBeenCalled()
|
||||
expect(callbacks.onShellExecutionStarted).toHaveBeenCalled()
|
||||
expect(callbacks.onShellExecutionComplete).toHaveBeenCalled()
|
||||
|
||||
expect(result).toBeTypeOf("string")
|
||||
expect(result).toContain("total")
|
||||
})
|
||||
})
|
||||
7
vitest.config.ts
Normal file
7
vitest.config.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { defineConfig } from "vitest/config"
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ["**/__tests__/**/*.spec.ts"],
|
||||
},
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue