Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f9e76a23
Unverified
Commit
f9e76a23
authored
Mar 19, 2019
by
Joe Haddad
Committed by
GitHub
Mar 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shrink the size of profiling test (#6723)
parent
bce75ae9
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
9 additions
and
292 deletions
+9
-292
hello-context.js
test/integration/profiling/components/hello-context.js
+0
-15
hello1.js
test/integration/profiling/components/hello1.js
+0
-3
hello2.js
test/integration/profiling/components/hello2.js
+0
-3
welcome.js
test/integration/profiling/components/welcome.js
+0
-19
another.js
test/integration/profiling/pages/another.js
+0
-8
counter.js
test/integration/profiling/pages/counter.js
+0
-33
bundle.js
test/integration/profiling/pages/dynamic/bundle.js
+0
-64
index.js
test/integration/profiling/pages/dynamic/index.js
+0
-7
no-chunk.js
test/integration/profiling/pages/dynamic/no-chunk.js
+0
-11
no-ssr-custom-loading.js
...egration/profiling/pages/dynamic/no-ssr-custom-loading.js
+0
-8
no-ssr.js
test/integration/profiling/pages/dynamic/no-ssr.js
+0
-5
ssr-true.js
test/integration/profiling/pages/dynamic/ssr-true.js
+0
-5
ssr.js
test/integration/profiling/pages/dynamic/ssr.js
+0
-5
error-in-browser-render-status-code.js
...on/profiling/pages/error-in-browser-render-status-code.js
+0
-13
error-in-browser-render.js
test/integration/profiling/pages/error-in-browser-render.js
+0
-9
error-in-ssr-render.js
test/integration/profiling/pages/error-in-ssr-render.js
+0
-6
finish-response.js
test/integration/profiling/pages/finish-response.js
+0
-11
prefetch.js
test/integration/profiling/pages/prefetch.js
+0
-28
process-env.js
test/integration/profiling/pages/process-env.js
+0
-12
index.test.js
test/integration/profiling/test/index.test.js
+9
-27
No files found.
test/integration/profiling/components/hello-context.js
deleted
100644 → 0
View file @
bce75ae9
import
React
from
'react'
import
PropTypes
from
'prop-types'
export
default
class
extends
React
.
Component
{
static
contextTypes
=
{
data
:
PropTypes
.
object
}
render
()
{
const
{
data
}
=
this
.
context
return
(
<
div
>
{
data
.
title
}
<
/div
>
)
}
}
test/integration/profiling/components/hello1.js
deleted
100644 → 0
View file @
bce75ae9
export
default
()
=>
(
<
p
>
Hello
World
1
<
/p
>
)
test/integration/profiling/components/hello2.js
deleted
100644 → 0
View file @
bce75ae9
export
default
()
=>
(
<
p
>
Hello
World
2
<
/p
>
)
test/integration/profiling/components/welcome.js
deleted
100644 → 0
View file @
bce75ae9
import
React
from
'react'
export
default
class
Welcome
extends
React
.
Component
{
state
=
{
name
:
null
}
componentDidMount
()
{
const
{
name
}
=
this
.
props
this
.
setState
({
name
})
}
render
()
{
const
{
name
}
=
this
.
state
if
(
!
name
)
return
null
return
(
<
p
>
Welcome
,
{
name
}
<
/p
>
)
}
}
test/integration/profiling/pages/another.js
deleted
100644 → 0
View file @
bce75ae9
import
Link
from
'next/link'
export
default
()
=>
(
<
div
>
<
Link
href
=
'/'
><
a
>
Index
Page
<
/a></
Link
>
<
p
>
Another
<
/p
>
<
/div
>
)
test/integration/profiling/pages/counter.js
deleted
100644 → 0
View file @
bce75ae9
import
Link
from
'next/link'
import
{
Component
}
from
'react'
import
Router
from
'next/router'
let
counter
=
0
export
default
class
extends
Component
{
increase
()
{
counter
++
this
.
forceUpdate
()
}
visitQueryStringPage
()
{
const
href
=
{
pathname
:
'/nav/querystring'
,
query
:
{
id
:
10
}
}
const
as
=
{
pathname
:
'/nav/querystring/10'
,
hash
:
'10'
}
Router
.
push
(
href
,
as
)
}
render
()
{
return
(
<
div
id
=
'counter-page'
>
<
Link
href
=
'/no-such-page'
><
a
id
=
'no-such-page'
>
No
Such
Page
<
/a></
Link
>
<
br
/>
<
Link
href
=
'/no-such-page'
prefetch
><
a
id
=
'no-such-page-prefetch'
>
No
Such
Page
(
with
prefetch
)
<
/a></
Link
>
<
p
>
This
is
the
home
.
<
/p
>
<
div
id
=
'counter'
>
Counter
:
{
counter
}
<
/div
>
<
button
id
=
'increase'
onClick
=
{()
=>
this
.
increase
()}
>
Increase
<
/button
>
<
/div
>
)
}
}
test/integration/profiling/pages/dynamic/bundle.js
deleted
100644 → 0
View file @
bce75ae9
import
React
from
'react'
import
dynamic
from
'next/dynamic'
import
Router
from
'next/router'
import
PropTypes
from
'prop-types'
const
HelloBundle
=
dynamic
({
modules
:
()
=>
{
const
components
=
{
HelloContext
:
import
(
'../../components/hello-context'
),
Hello1
:
import
(
'../../components/hello1'
),
Hello2
:
import
(
'../../components/hello2'
)
}
return
components
},
render
:
(
props
,
{
HelloContext
,
Hello1
,
Hello2
})
=>
(
<
div
>
<
h1
>
{
props
.
title
}
<
/h1
>
<
HelloContext
/>
<
Hello1
/>
{
props
.
showMore
?
<
Hello2
/>
:
null
}
<
/div
>
)
})
export
default
class
Bundle
extends
React
.
Component
{
static
childContextTypes
=
{
data
:
PropTypes
.
object
}
static
getInitialProps
({
query
})
{
return
{
showMore
:
Boolean
(
query
.
showMore
)
}
}
getChildContext
()
{
return
{
data
:
{
title
:
'ZEIT Rocks'
}
}
}
toggleShowMore
()
{
if
(
this
.
props
.
showMore
)
{
Router
.
push
(
'/dynamic/bundle'
)
return
}
Router
.
push
(
'/dynamic/bundle?showMore=1'
)
}
render
()
{
const
{
showMore
}
=
this
.
props
return
(
<
div
>
<
HelloBundle
showMore
=
{
showMore
}
title
=
"Dynamic Bundle"
/>
<
button
id
=
"toggle-show-more"
onClick
=
{()
=>
this
.
toggleShowMore
()}
>
Toggle
Show
More
<
/button
>
<
/div
>
)
}
}
test/integration/profiling/pages/dynamic/index.js
deleted
100644 → 0
View file @
bce75ae9
import
Link
from
'next/link'
export
default
()
=>
(
<
div
>
<
Link
href
=
'/dynamic/no-chunk'
><
a
>
No
Chunk
<
/a></
Link
>
<
/div
>
)
test/integration/profiling/pages/dynamic/no-chunk.js
deleted
100644 → 0
View file @
bce75ae9
import
dynamic
from
'next/dynamic'
import
Welcome
from
'../../components/welcome'
const
Welcome2
=
dynamic
(
import
(
'../../components/welcome'
))
export
default
()
=>
(
<
div
>
<
Welcome
name
=
'normal'
/>
<
Welcome2
name
=
'dynamic'
/>
<
/div
>
)
test/integration/profiling/pages/dynamic/no-ssr-custom-loading.js
deleted
100644 → 0
View file @
bce75ae9
import
dynamic
from
'next/dynamic'
const
Hello
=
dynamic
(
import
(
'../../components/hello1'
),
{
ssr
:
false
,
loading
:
()
=>
(
<
p
>
LOADING
<
/p>
)
})
export
default
Hello
test/integration/profiling/pages/dynamic/no-ssr.js
deleted
100644 → 0
View file @
bce75ae9
import
dynamic
from
'next/dynamic'
const
Hello
=
dynamic
(
import
(
'../../components/hello1'
),
{
ssr
:
false
})
export
default
Hello
test/integration/profiling/pages/dynamic/ssr-true.js
deleted
100644 → 0
View file @
bce75ae9
import
dynamic
from
'next/dynamic'
const
Hello
=
dynamic
(
import
(
'../../components/hello1'
),
{
ssr
:
true
})
export
default
Hello
test/integration/profiling/pages/dynamic/ssr.js
deleted
100644 → 0
View file @
bce75ae9
import
dynamic
from
'next/dynamic'
const
Hello
=
dynamic
(
import
(
'../../components/hello1'
))
export
default
Hello
test/integration/profiling/pages/error-in-browser-render-status-code.js
deleted
100644 → 0
View file @
bce75ae9
import
React
from
'react'
export
default
class
ErrorInRenderPage
extends
React
.
Component
{
render
()
{
if
(
typeof
window
!==
'undefined'
)
{
const
error
=
new
Error
(
'An Expected error occurred'
)
// This will be extracted by getInitialProps in the _error page,
// which will result in a different error message being rendered.
error
.
statusCode
=
404
throw
error
}
return
<
div
/>
}
}
test/integration/profiling/pages/error-in-browser-render.js
deleted
100644 → 0
View file @
bce75ae9
import
React
from
'react'
export
default
class
ErrorInRenderPage
extends
React
.
Component
{
render
()
{
if
(
typeof
window
!==
'undefined'
)
{
throw
new
Error
(
'An Expected error occured'
)
}
return
<
div
/>
}
}
test/integration/profiling/pages/error-in-ssr-render.js
deleted
100644 → 0
View file @
bce75ae9
import
React
from
'react'
export
default
class
ErrorInRenderPage
extends
React
.
Component
{
render
()
{
throw
new
Error
(
'An Expected error occured'
)
}
}
test/integration/profiling/pages/finish-response.js
deleted
100644 → 0
View file @
bce75ae9
import
React
,
{
Component
}
from
'react'
export
default
class
extends
Component
{
static
getInitialProps
({
res
})
{
res
.
end
(
'hi'
)
}
render
()
{
return
<
div
>
hi
<
/div
>
}
}
test/integration/profiling/pages/prefetch.js
deleted
100644 → 0
View file @
bce75ae9
import
Link
from
'next/link'
export
default
()
=>
{
return
<
div
>
<
ul
>
<
li
>
<
Link
href
=
'/'
prefetch
>
<
a
>
index
<
/a
>
<
/Link
>
<
/li
>
<
li
>
<
Link
href
=
'/process-env'
prefetch
>
<
a
>
process
env
<
/a
>
<
/Link
>
<
/li
>
<
li
>
<
Link
href
=
'/counter'
prefetch
>
<
a
>
counter
<
/a
>
<
/Link
>
<
/li
>
<
li
>
<
Link
href
=
'/about'
prefetch
>
<
a
>
about
<
/a
>
<
/Link
>
<
/li
>
<
/ul
>
<
/div
>
}
test/integration/profiling/pages/process-env.js
deleted
100644 → 0
View file @
bce75ae9
if
(
process
.
browser
)
{
global
.
__THIS_SHOULD_ONLY_BE_DEFINED_IN_BROWSER_CONTEXT__
=
true
}
if
(
!
process
.
browser
)
{
global
.
__THIS_SHOULD_ONLY_BE_DEFINED_IN_SERVER_CONTEXT__
=
true
}
export
default
()
=>
(
<
div
id
=
'node-env'
>
{
process
.
env
.
NODE_ENV
}
<
/div
>
)
test/integration/profiling/test/index.test.js
View file @
f9e76a23
/* eslint-env jest */
/* global jasmine */
import
{
join
}
from
'path'
import
{
nextServer
,
nextBuild
,
startApp
,
stopApp
,
renderViaHTTP
}
from
'next-test-utils'
import
{
nextBuild
}
from
'next-test-utils'
import
fs
from
'fs'
const
appDir
=
join
(
__dirname
,
'../'
)
let
appPort
let
server
let
app
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
5
const
context
=
{}
describe
(
'Profiling Usage'
,
()
=>
{
beforeAll
(
async
()
=>
{
await
nextBuild
(
appDir
)
app
=
nextServer
({
dir
:
join
(
__dirname
,
'../'
),
dev
:
false
,
quiet
:
true
})
server
=
await
startApp
(
app
)
context
.
appPort
=
appPort
=
server
.
address
().
port
})
afterAll
(()
=>
stopApp
(
server
))
describe
(
'With basic usage'
,
()
=>
{
it
(
'should render the page'
,
async
()
=>
{
expect
(
fs
.
existsSync
(
join
(
appDir
,
'.next'
,
'profile-events-server.json'
))).
toBe
(
true
)
expect
(
fs
.
existsSync
(
join
(
appDir
,
'.next'
,
'profile-events-client.json'
))).
toBe
(
true
)
const
html
=
await
renderViaHTTP
(
appPort
,
'/'
)
expect
(
html
).
toMatch
(
/Hello World/
)
describe
(
'Profiling the build'
,
()
=>
{
it
(
'should emit files'
,
async
()
=>
{
expect
(
fs
.
existsSync
(
join
(
appDir
,
'.next'
,
'profile-events-server.json'
))
).
toBe
(
true
)
expect
(
fs
.
existsSync
(
join
(
appDir
,
'.next'
,
'profile-events-client.json'
))
).
toBe
(
true
)
})
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment