-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vitest): use correct type for defineProject to allow usage in mer…
…geConfig (#4498)
- Loading branch information
1 parent
ac3d300
commit 7dee832
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { describe, expectTypeOf, test } from 'vitest' | ||
import { type UserWorkspaceConfig, defineConfig, defineProject, defineWorkspace, mergeConfig } from 'vitest/config' | ||
|
||
const expectMainTestConfig = expectTypeOf(defineConfig).parameter(0).resolves.toHaveProperty('test').exclude<undefined>() | ||
const expectProjectTestConfig = expectTypeOf(defineProject).parameter(0).resolves.toHaveProperty('test').exclude<undefined>() | ||
|
||
describe('define project helper', () => { | ||
test('cannot define non-project fields on a project config', () => { | ||
expectProjectTestConfig.toHaveProperty('name') | ||
expectMainTestConfig.toHaveProperty('name') | ||
|
||
expectProjectTestConfig.not.toHaveProperty('pool') | ||
expectMainTestConfig.toHaveProperty('pool') | ||
|
||
expectProjectTestConfig.not.toHaveProperty('coverage') | ||
expectMainTestConfig.toHaveProperty('coverage') | ||
}) | ||
}) | ||
|
||
describe('merge config helper', () => { | ||
test('types are not conflicting', () => { | ||
expectTypeOf(mergeConfig( | ||
defineConfig({}), | ||
defineProject({ test: { name: 'test' } }), | ||
)).toMatchTypeOf<Record<string, unknown>>() | ||
}) | ||
}) | ||
|
||
describe('workspace config', () => { | ||
test('correctly defines return type', () => { | ||
expectTypeOf(defineWorkspace([{ test: { name: 'test' } }])).items.toMatchTypeOf<UserWorkspaceConfig>() | ||
expectTypeOf(defineWorkspace(['packages/*'])).items.toBeString() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"exclude": [ | ||
"**/dist/**" | ||
] | ||
} |