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

Add integration test for #1347.
This commit is contained in:
Sabertaz 2022-05-22 14:48:08 +08:00 committed by GitHub
parent e771bcbfd4
commit f5cb4bfcc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -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
})

View File

@ -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()
})

View File

@ -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: {