Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(config-setupFiles): add integration test #1353

Merged
merged 1 commit into from May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/global-setup/setupFiles/without-relative-path-prefix.ts
@@ -0,0 +1,11 @@
import { afterAll, beforeAll } from 'vitest'

beforeAll(() => {
// @ts-expect-error type
global.loaded = true
})

afterAll(() => {
// @ts-expect-error type
delete global.loaded
})
6 changes: 6 additions & 0 deletions test/global-setup/test/setup-files.test.ts
Expand Up @@ -5,3 +5,9 @@ test('something has been added to global by setupFiles entry', async () => {
const result = something
expect(result).toBe('something')
})

test('setup file has been loaded without relative path prefix', () => {
// @ts-expect-error type
const result = loaded
expect(result).toBeTruthy()
})
7 changes: 6 additions & 1 deletion test/global-setup/vitest.config.ts
Expand Up @@ -6,7 +6,12 @@ export default defineConfig({
plugins: [{
name: 'a-vitest-plugin-that-changes-config',
config: () => ({
test: { setupFiles: ['./setupFiles/add-something-to-global.ts'] },
test: {
setupFiles: [
'./setupFiles/add-something-to-global.ts',
'setupFiles/without-relative-path-prefix.ts',
],
},
}),
}],
test: {
Expand Down