Skip to content

Commit 588f768

Browse files
authored
fix(browser): don't print the deprecation notice in node_modules (#8779)
1 parent a7c4f6f commit 588f768

File tree

5 files changed

+9
-24
lines changed

5 files changed

+9
-24
lines changed

packages/browser/src/node/plugins/pluginContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function BrowserContext(globalServer: ParentBrowserProject): Plug
2525
return VIRTUAL_ID_CONTEXT
2626
}
2727
if (id === DEPRECATED_ID_CONTEXT) {
28-
if (importer) {
28+
if (importer && !importer.includes('/node_modules/')) {
2929
globalServer.vitest.logger.deprecate(
3030
`${importer} tries to load a deprecated "${id}" module. `
3131
+ `This import will stop working in the next major version. `

pnpm-lock.yaml

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browser/fixtures/locators/blog.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { page, userEvent } from 'vitest/browser'
33
import Blog from '../../src/blog-app/blog'
44

55
test('renders blog posts', async () => {
6-
const screen = page.render(<Blog />)
6+
const screen = await page.render(<Blog />)
77

88
await expect.element(screen.getByRole('heading', { name: 'Blog' })).toBeInTheDocument()
99

test/browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"react-dom": "^19.1.1",
4444
"url": "^0.11.4",
4545
"vitest": "workspace:*",
46-
"vitest-browser-react": "^0.3.0",
46+
"vitest-browser-react": "^2.0.0",
4747
"ws": "catalog:"
4848
}
4949
}

test/browser/specs/locators.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
1-
import { expect, test, vi } from 'vitest'
1+
import { expect, test } from 'vitest'
22
import { instances, runBrowserTests } from './utils'
33

44
test('locators work correctly', async () => {
5-
const log = vi.fn()
65
const { stderr, stdout } = await runBrowserTests({
76
root: './fixtures/locators',
87
reporters: [
98
['verbose', { isTTY: false }],
10-
{
11-
onInit(vitest) {
12-
vitest.logger.deprecate = log
13-
},
14-
},
159
],
1610
})
1711

1812
expect(stderr).toReportNoErrors()
19-
expect(log).toHaveBeenCalledWith(
20-
expect.stringContaining(
21-
`tries to load a deprecated "@vitest/browser/context" module. `
22-
+ `This import will stop working in the next major version. Please, use "vitest/browser" instead.`,
23-
),
24-
)
2513

2614
instances.forEach(({ browser }) => {
2715
expect(stdout).toReportPassedTest('blog.test.tsx', browser)

0 commit comments

Comments
 (0)