Nine tests in this file failed about half the time — including on a clean
origin/main worktree, which is why main's own Unit tests workflow has been red
on most recent commits. They took the PR out of the merge queue.
The cause was a mock one function short of the component. setupEditor's promql
branch calls, in order:
monaco.languages.register({ id: "promql" })
monaco.languages.setMonarchTokensProvider("promql", ...)
monaco.languages.setLanguageConfiguration("promql", ...) <-- not mocked
so the "should support promql language" mount threw mid-setup. The vitest config
sets dangerouslyIgnoreUnhandledErrors, so nothing reported it; what showed
instead was later tests in the file hanging on vi.waitFor(addCommand) and timing
out at 5000ms. Whether they hung depended on how those aborted mounts
interleaved with live ones, which is what made it bimodal: ~52ms or never.
Adding setLanguageConfiguration takes it from roughly one run in two to 8/8
clean, and the full suite passes.
Also replaced the `vi.spyOn(document, "getElementById")` in three describes with
a real <div id="test-editor"> attached to the document. setupEditor retries that
lookup five times on a 100ms timer and then gives up WITHOUT reaching
addCommand, and the spy made "does this mount find its element" depend on mock
lifecycle across three describes while ~50 mounts from earlier describes were
still polling on their own timers. That alone did not fix the flake — measured,
2 of 5 runs still failed — but it removes a whole class of ordering dependency
from a file that had just demonstrated it has one.
|
||
|---|---|---|
| .. | ||
| cypress/e2e | ||
| public | ||
| scripts | ||
| src | ||
| test-results | ||
| tests/unit | ||
| .gitignore | ||
| .nvmrc | ||
| .prettierignore | ||
| .prettierrc.json | ||
| .stylelintrc.json | ||
| AGENTS.md | ||
| README.md | ||
| coverage.sh | ||
| cypress.config.ts | ||
| env.d.ts | ||
| eslint.config.js | ||
| eslint.sh | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.js | ||
| run_all.sh | ||
| sbom.json | ||
| serve.json | ||
| tsconfig.app.json | ||
| tsconfig.config.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| tsconfig.vitest.json | ||
| tsconfig.vitest.tsbuildinfo | ||
| vite.config.ts | ||
| vitest.chat-history.config.ts | ||
| vitest.config.ts | ||
README.md
web
This template should help get you started developing with Vue 3 in Vite.
Recommended IDE Setup
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
Type Support for .vue Imports in TS
TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensionsfrom VSCode's command palette - Find
TypeScript and JavaScript Language Features, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Windowfrom the command palette.
Customize configuration
See Vite Configuration Reference.
Project Setup
npm install
Compile and Hot-Reload for Development
For stand-alone UI development environment, create .env file and which contains below environment variable
VITE_OPENOBSERVE_ENDPOINT=http://localhost:5080/
npm run dev
Type-Check, Compile and Minify for Production
npm run build
Run Unit Tests with Vitest
npm run test:unit
Run End-to-End Tests with Cypress
npm run test:e2e:dev
This runs the end-to-end tests against the Vite development server. It is much faster than the production build.
But it's still recommended to test the production build with test:e2e before deploying (e.g. in CI environments):
npm run build
npm run test:e2e
Lint with ESLint
npm run lint