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 section for jetbrains webstorm debugging #24556

Merged
merged 3 commits into from
May 23, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/advanced-features/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Create a file named `.vscode/launch.json` at the root of your project with the f

Now go to the Debug panel (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd> on Windows/Linux, <kbd>⇧</kbd>+<kbd>⌘</kbd>+<kbd>D</kbd> on macOS), select a launch configuration, then press <kbd>F5</kbd> or select **Debug: Start Debugging** from the Command Palette to start your debugging session.

## Using the Debugger in Jetbrains WebStorm

Click the drop down menu listing the runtime configuration, and click `Edit Configurations...`. Create a `Javascript Debug` debug configuration with `http://localhost:3000` as the URL. Customize to your liking (e.g. Browser for debugging, store as project file), and click `OK`. Run this debug configuration, and the selected browser should automatically open. At this point, you should have 2 applications in debug mode: the NextJS node application, and the client/ browser application.

## Debugging with Chrome DevTools

### Client-side code
Expand Down
69 changes: 45 additions & 24 deletions test/e2e/reload-scroll-backforward-restoration/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NextInstance } from 'test/lib/next-modes/base'
import { check } from 'next-test-utils'
import { join } from 'path'
import webdriver from 'next-webdriver'
import assert from 'assert'

describe('reload-scroll-back-restoration', () => {
let next: NextInstance
Expand Down Expand Up @@ -53,12 +54,17 @@ describe('reload-scroll-back-restoration', () => {
/routeChangeComplete/
)

expect(scrollPositionMemories[1].x).toBe(
Math.floor(await browser.eval(() => window.scrollX))
)
expect(scrollPositionMemories[1].y).toBe(
Math.floor(await browser.eval(() => window.scrollY))
)
await check(async () => {
assert.equal(
scrollPositionMemories[1].x,
Math.floor(await browser.eval(() => window.scrollX))
)
assert.equal(
scrollPositionMemories[1].y,
Math.floor(await browser.eval(() => window.scrollY))
)
return 'success'
}, 'success')

await browser.refresh()

Expand All @@ -69,12 +75,17 @@ describe('reload-scroll-back-restoration', () => {
/routeChangeComplete/
)

expect(scrollPositionMemories[0].x).toBe(
Math.floor(await browser.eval(() => window.scrollX))
)
expect(scrollPositionMemories[0].y).toBe(
Math.floor(await browser.eval(() => window.scrollY))
)
await check(async () => {
assert.equal(
scrollPositionMemories[0].x,
Math.floor(await browser.eval(() => window.scrollX))
)
assert.equal(
scrollPositionMemories[0].y,
Math.floor(await browser.eval(() => window.scrollY))
)
return 'success'
}, 'success')
})

it('should restore the scroll position on navigating forward', async () => {
Expand Down Expand Up @@ -119,12 +130,17 @@ describe('reload-scroll-back-restoration', () => {
/routeChangeComplete/
)

expect(scrollPositionMemories[1].x).toBe(
Math.floor(await browser.eval(() => window.scrollX))
)
expect(scrollPositionMemories[1].y).toBe(
Math.floor(await browser.eval(() => window.scrollY))
)
await check(async () => {
assert.equal(
scrollPositionMemories[1].x,
Math.floor(await browser.eval(() => window.scrollX))
)
assert.equal(
scrollPositionMemories[1].y,
Math.floor(await browser.eval(() => window.scrollY))
)
return 'success'
}, 'success')

await browser.refresh()

Expand All @@ -135,11 +151,16 @@ describe('reload-scroll-back-restoration', () => {
/routeChangeComplete/
)

expect(scrollPositionMemories[2].x).toBe(
Math.floor(await browser.eval(() => window.scrollX))
)
expect(scrollPositionMemories[2].y).toBe(
Math.floor(await browser.eval(() => window.scrollY))
)
await check(async () => {
assert.equal(
scrollPositionMemories[2].x,
Math.floor(await browser.eval(() => window.scrollX))
)
assert.equal(
scrollPositionMemories[2].y,
Math.floor(await browser.eval(() => window.scrollY))
)
return 'success'
}, 'success')
})
})