chore: set FORCE_COLOR=1 in test env for realistic ANSI output
Tests must exercise the same ANSI code paths users see. Without FORCE_COLOR, chalk disables all color in non-TTY test environments, making style bugs invisible to the test suite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
- Always use `defineComponent()` to define components. Never use bare `{ setup() {} }` objects — they lack component scope, so `inject`, `watch`, and `onScopeDispose` won't work correctly.
|
- Always use `defineComponent()` to define components. Never use bare `{ setup() {} }` objects — they lack component scope, so `inject`, `watch`, and `onScopeDispose` won't work correctly.
|
||||||
- Vue SFCs must use `<script setup>` unless there's an explicit reason not to.
|
- Vue SFCs must use `<script setup>` unless there's an explicit reason not to.
|
||||||
- Bug fixes must follow test-first: write a failing test that reproduces the bug, then fix the code and verify the test passes.
|
- Bug fixes must follow test-first: write a failing test that reproduces the bug, then fix the code and verify the test passes.
|
||||||
|
- Tests must simulate real user conditions. Non-TTY environments disable chalk colors — use `FORCE_COLOR` env var so ANSI output is always exercised. A bug invisible in tests but visible in a real terminal is a testing gap, not a minor issue.
|
||||||
- When debugging color/ANSI output in non-TTY environments (e.g. Claude Code shell), use `FORCE_COLOR=3` env var to force chalk to output ANSI codes.
|
- When debugging color/ANSI output in non-TTY environments (e.g. Claude Code shell), use `FORCE_COLOR=3` env var to force chalk to output ANSI codes.
|
||||||
- After completing any task, run `vp run ready` (or `vpr ready`) to verify: lint, type-check, test all packages, and build.
|
- After completing any task, run `vp run ready` (or `vpr ready`) to verify: lint, type-check, test all packages, and build.
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,9 @@
|
|||||||
import chalk from "chalk";
|
import { expect, test } from "vite-plus/test";
|
||||||
import { afterEach, beforeEach, expect, test } from "vite-plus/test";
|
|
||||||
import { render } from "@vue-tui/testing";
|
import { render } from "@vue-tui/testing";
|
||||||
import { Box, Text } from "@vue-tui/runtime";
|
import { Box, Text } from "@vue-tui/runtime";
|
||||||
|
|
||||||
const BG_BLUE = "\x1b[44m";
|
const BG_BLUE = "\x1b[44m";
|
||||||
|
|
||||||
let prevLevel: typeof chalk.level;
|
|
||||||
beforeEach(() => {
|
|
||||||
prevLevel = chalk.level;
|
|
||||||
chalk.level = 1;
|
|
||||||
});
|
|
||||||
afterEach(() => {
|
|
||||||
chalk.level = prevLevel;
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Box backgroundColor produces ANSI background codes", async () => {
|
test("Box backgroundColor produces ANSI background codes", async () => {
|
||||||
const { frames } = await render(
|
const { frames } = await render(
|
||||||
() => <Box backgroundColor="blue" width={5} height={1} />,
|
() => <Box backgroundColor="blue" width={5} height={1} />,
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import vueJsx from "@vitejs/plugin-vue-jsx";
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vueJsx()],
|
plugins: [vueJsx()],
|
||||||
|
test: {
|
||||||
|
// chalk disables color in non-TTY envs; force it on so ANSI style bugs don't hide from tests
|
||||||
|
env: { FORCE_COLOR: "1" },
|
||||||
|
},
|
||||||
lint: {
|
lint: {
|
||||||
options: { typeAware: true, typeCheck: true },
|
options: { typeAware: true, typeCheck: true },
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user