Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
docs: update reproduction to use vitest directly
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpatiiuk committed Oct 14, 2024
1 parent fba068a commit 0865077
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion packages/calcite-components/src/utils/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { describe, expect, it } from 'vitest';

describe('1', () => {
it('2', () => {
expect('a').toBe('b');
expect('a').toBe('a');
});
});

0 comments on commit 0865077

Please sign in to comment.