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

Add tests for searchParams dev warning #16798

Merged
merged 4 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/next-server/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export const urlObjectKeys = [
'protocol',
'query',
'search',
'searchParams',
'slashes',
]

Expand Down
9 changes: 9 additions & 0 deletions test/integration/dynamic-routing/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import Link from 'next/link'
import { useRouter } from 'next/router'

if (typeof window !== 'undefined') {
window.caughtWarns = []
const origWarn = window.console.warn
window.console.warn = function (...args) {
window.caughtWarns.push(args)
origWarn(...args)
}
}

const Page = () => {
return (
<div>
Expand Down
6 changes: 6 additions & 0 deletions test/integration/dynamic-routing/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ function runTests(dev) {
expect(url).toBe('?fromHome=true')
})

it('should not have any console warnings', async () => {
const browser = await webdriver(appPort, '/')
const caughtWarns = await browser.eval(`window.caughtWarns`)
expect(caughtWarns).toEqual([])
})
ijjk marked this conversation as resolved.
Show resolved Hide resolved

it('should navigate to a dynamic page successfully', async () => {
let browser
try {
Expand Down