Skip to content

Commit

Permalink
feat(plugin-vitest): support Vitest 2 (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong authored Dec 8, 2024
1 parent 92db1cc commit f3d116d
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 205 deletions.
4 changes: 2 additions & 2 deletions internal/vitest-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"main": "./src/index.js",
"devDependencies": {
"@internal/tsconfig": "workspace:^",
"vitest": "^1.2.2"
"vitest": "^2.1.8"
},
"peerDependencies": {
"vitest": "^1"
"vitest": "^2"
},
"dependencies": {
"@vitest/coverage-v8": "^1.2.2"
Expand Down
5 changes: 5 additions & 0 deletions modules/logger/.changes/000-dark-bananas-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: patch
---

Internal test changes to support Vitest 2
6 changes: 3 additions & 3 deletions modules/logger/src/__tests__/LogStep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('LogStep', () => {

expect(out).toEqual(
` ┌ tacos
[36m[1mLOG[22m[39m hellooooo
[32m✔[39m [2m0ms[22m
${pc.cyan(pc.bold('LOG'))} hellooooo
${pc.green('✔')} ${pc.dim('0ms')}
`,
);
});
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('LogStep', () => {
│info
│log
│debug
[31m✘[39m [2m0ms[22m
${pc.red('✘')} ${pc.dim('0ms')}
`);
});

Expand Down
5 changes: 5 additions & 0 deletions modules/onerepo/.changes/003-dark-bananas-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: patch
---

Internal test changes to support Vitest 2
15 changes: 15 additions & 0 deletions modules/onerepo/src/core/changes/__tests__/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ import * as migrate from '../migrate';
const graph = getGraph(path.join(__dirname, '__fixtures__/with-entries'));
const { run } = getCommand(migrate, graph);

vi.mock('glob', async (requireActual) => {
const actual = await requireActual();
const mocked = {};
for (const [key, val] of Object.entries(actual as Record<string, unknown>)) {
if (typeof val === 'function') {
// @ts-ignore
mocked[key] = vi.fn(val);
} else {
// @ts-ignore
mocked[key] = actual[key];
}
}
return mocked;
});

describe('migrate changes', () => {
beforeEach(() => {
vi.spyOn(Date, 'now').mockReturnValue(1706903142100);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"onerepo": "workspace:^",
"prettier": "^3.0.0",
"typescript": "^5.3.3",
"vitest": "^1.2.2"
"vitest": "^2.1.8"
},
"engines": {
"node": "^18 || ^20"
Expand Down
5 changes: 5 additions & 0 deletions plugins/vitest/.changes/000-every-taxes-open.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
type: minor
---

Supports Vitest ^2.0.0
2 changes: 1 addition & 1 deletion plugins/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"peerDependencies": {
"onerepo": "^1",
"vitest": "^0 || ^1"
"vitest": "^0 || ^1 || ^2"
},
"engines": {
"node": "^18 || ^20"
Expand Down
Loading

0 comments on commit f3d116d

Please sign in to comment.