From 086507767b376edafb5be604942561eafa1a7da4 Mon Sep 17 00:00:00 2001 From: Max Patiiuk Date: Mon, 14 Oct 2024 10:32:16 -0700 Subject: [PATCH] docs: update reproduction to use vitest directly --- README.md | 42 +++++++++---------- .../src/utils/component.spec.ts | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 75fb2a6..8dd642a 100644 --- a/README.md +++ b/README.md @@ -5,37 +5,37 @@ executed with the CWD set to the monorepo root rather than the package root. The `vite.config.ts` is correctly executed with the package root as CWD. -Logs from the "Output" of the "Vitest" extension: +`npx vitest run` output: ```log -[INFO 7:25:38 PM] [v1.6.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace. -[INFO 7:25:38 PM] [API] Running Vitest v2.1.2 (vitest-wrong-cwd/vitest.workspace.ts) with Node.js@v20.16.0: /Users/mak13180/.nvm/versions/node/v20.16.0/bin/node -[INFO 7:25:38 PM] [Worker] 🟥 vite.config.ts cwd: /Users/mak13180/site/esri/vitest-wrong-cwd/packages/calcite-components -[INFO 7:25:38 PM] [API] Vitest v2.1.2 (vitest-wrong-cwd/vitest.workspace.ts) child process 45982 created -[INFO 7:25:38 PM] [VSCODE] Watching vitest-wrong-cwd with pattern **/* -[INFO 7:25:45 PM] [API] Collecting tests: packages/calcite-components/src/utils/component.spec.ts -[INFO 7:25:45 PM] [Worker] 🟥 globalSetup.ts cwd: /Users/mak13180/site/esri/vitest-wrong-cwd +npx vitest run +🟥 vite.config.ts cwd: /home/maxpatiiuk/vitest-wrong-dir/packages/calcite-components + + RUN v2.1.2 /home/maxpatiiuk/vitest-wrong-dir + +🟥 globalSetup.ts cwd: /home/maxpatiiuk/vitest-wrong-dir + + ✓ |@esri/calcite-components| src/utils/component.spec.ts (1) + ✓ 1 (1) + ✓ 2 + + Test Files 1 passed (1) + Tests 1 passed (1) + Start at 10:30:50 + Duration 1.25s (transform 95ms, setup 0ms, collect 30ms, tests 1ms, environment 0ms, prepare 501ms) ``` ## Reproduction -1. Clone this repository +1. Clone this repository & install dependencies (or use Stackblitz): ```sh git clone https://github.com/maxpatiiuk/vitest-wrong-cwd cd vite-wrong-cwd - ``` - -2. Install dependencies - - ```sh npm install ``` -3. In VS Code with the "Vitest" extension installed, open the - `packages/calcite-components/src/utils/component.spec.ts` file from this - repository. - -4. Open the "Output -> Vitest" panel in VS Code to see the log output for the - "Vitest" extension. See that the `globalSetup` script is executed with the - CWD set to the monorepo root rather than package root. +2. Run `npx vitest run` from monorepo root. See that the `vite.config.ts` is + correctly executed with CWD set to package root. At the same time, + `globalSetup` script is unexpectedly executed with CWD set to the monorepo + root. diff --git a/packages/calcite-components/src/utils/component.spec.ts b/packages/calcite-components/src/utils/component.spec.ts index f01fec6..0b015ef 100644 --- a/packages/calcite-components/src/utils/component.spec.ts +++ b/packages/calcite-components/src/utils/component.spec.ts @@ -2,6 +2,6 @@ import { describe, expect, it } from 'vitest'; describe('1', () => { it('2', () => { - expect('a').toBe('b'); + expect('a').toBe('a'); }); });