forked from vitest-dev/vitest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: failing test cases for vitest-dev#3659
- Loading branch information
1 parent
893e90b
commit 7d8413a
Showing
6 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
|
||
import { expect, test } from 'vitest' | ||
|
||
test('Leaking globals not found', async () => { | ||
(globalThis as any).__leaking_from_happy_dom = 'leaking' | ||
expect((globalThis as any).__leaking_from_node).toBe(undefined) | ||
expect((globalThis as any).__leaking_from_jsdom).toBe(undefined) | ||
}) |
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,11 @@ | ||
/** | ||
* @vitest-environment jsdom | ||
*/ | ||
|
||
import { expect, test } from 'vitest' | ||
|
||
test('Leaking globals not found', async () => { | ||
(globalThis as any).__leaking_from_jsdom = 'leaking' | ||
expect((globalThis as any).__leaking_from_node).toBe(undefined) | ||
expect((globalThis as any).__leaking_from_happy_dom).toBe(undefined) | ||
}) |
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,11 @@ | ||
/** | ||
* @vitest-environment node | ||
*/ | ||
|
||
import { expect, test } from 'vitest' | ||
|
||
test('Leaking globals not found', async () => { | ||
(globalThis as any).__leaking_from_node = 'leaking' | ||
expect((globalThis as any).__leaking_from_jsdom).toBe(undefined) | ||
expect((globalThis as any).__leaking_from_happy_dom).toBe(undefined) | ||
}) |
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,12 @@ | ||
{ | ||
"name": "@vitest/test-run", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest" | ||
}, | ||
"devDependencies": { | ||
"happy-dom": "latest", | ||
"vite": "latest", | ||
"vitest": "workspace:*" | ||
} | ||
} |
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,26 @@ | ||
import { type UserConfig, expect, test } from 'vitest' | ||
|
||
import { runVitest } from '../../test-utils' | ||
|
||
const configs: UserConfig[] = [ | ||
{ isolate: false, singleThread: true }, | ||
{ isolate: false, singleThread: false }, | ||
{ isolate: false, threads: true, minThreads: 1, maxThreads: 1 }, | ||
{ isolate: false, threads: false }, | ||
] | ||
|
||
test.each(configs)('should isolate environments when %s', async (config) => { | ||
const { exitCode, stderr, stdout } = await runVitest({ | ||
root: './fixtures', | ||
...config, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
expect(exitCode).toBe(0) | ||
|
||
expect(stdout).toContain('✓ test/node.test.ts > Leaking globals not found') | ||
expect(stdout).toContain('✓ test/happy-dom.test.ts > Leaking globals not found') | ||
expect(stdout).toContain('✓ test/jsdom.test.ts > Leaking globals not found') | ||
expect(stdout).toContain('Test Files 3 passed (3)') | ||
expect(stdout).toContain('Tests 3 passed (3)') | ||
}) |
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,7 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ['./test/**/*'], | ||
}, | ||
}) |