color.test.ts
This file
Path
src/utils/color.test.ts
49 lines · 1.4 KiB · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than f0b094d point at it.
Merge commit from forkYusuke Wadabefore adoptionf0b094d
lines 1–49why, one step back1import * as esbuild from 'esbuild'2import { getColorEnabled, getColorEnabledAsync } from './color'34describe('getColorEnabled() / getColorEnabledAsync() - With colors enabled', () => {5 it('should return true', async () => {6 expect(getColorEnabled()).toBe(true)7 expect(await getColorEnabledAsync()).toBe(true)8 })9})1011describe('getColorEnabled() / getColorEnabledAsync() - With NO_COLOR environment variable set', () => {12 beforeAll(() => {13 vi.stubEnv('NO_COLOR', '1')14 })1516 afterAll(() => {17 vi.unstubAllEnvs()18 })1920 it('should return false', async () => {21 expect(getColorEnabled()).toBe(false)22 expect(await getColorEnabledAsync()).toBe(false)23 })24})2526describe('esbuild compatibility test', () => {27 it('should build color.ts with esbuild without errors', async () => {28 try {29 const result = await esbuild.build({30 entryPoints: [__filename.replace('.test.ts', '.ts')],31 bundle: true,32 format: 'esm',33 target: 'es2022',34 write: false,35 logLevel: 'silent',36 external: [],37 })3839 expect(result.errors).toHaveLength(0)40 expect(result.warnings).toHaveLength(0)41 expect(result.outputFiles).toHaveLength(1)4243 const outputContent = result.outputFiles[0].text44 expect(outputContent).toBeDefined()45 } catch (error) {46 throw new Error(`esbuild failed: ${error}`)47 }48 })49})