Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
fb73ef7d
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
fb73ef7d
编写于
6月 18, 2019
作者:
J
Joe Haddad
提交者:
GitHub
6月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `next/dynamic` test (#7600)
上级
033dd5ed
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
109 addition
and
0 deletion
+109
-0
test/integration/next-dynamic/apples/index.js
test/integration/next-dynamic/apples/index.js
+1
-0
test/integration/next-dynamic/components/one.js
test/integration/next-dynamic/components/one.js
+6
-0
test/integration/next-dynamic/components/three.js
test/integration/next-dynamic/components/three.js
+3
-0
test/integration/next-dynamic/components/two.js
test/integration/next-dynamic/components/two.js
+6
-0
test/integration/next-dynamic/pages/index.js
test/integration/next-dynamic/pages/index.js
+25
-0
test/integration/next-dynamic/test/index.test.js
test/integration/next-dynamic/test/index.test.js
+68
-0
未找到文件。
test/integration/next-dynamic/apples/index.js
0 → 100644
浏览文件 @
fb73ef7d
export
default
'
foobar
'
test/integration/next-dynamic/components/one.js
0 → 100644
浏览文件 @
fb73ef7d
import
something
from
'
../apples
'
export
default
()
=>
{
// have to do something with module so it is not tree shaken
console
.
log
(
something
)
return
'
1
'
}
test/integration/next-dynamic/components/three.js
0 → 100644
浏览文件 @
fb73ef7d
export
default
()
=>
{
return
'
3
'
}
test/integration/next-dynamic/components/two.js
0 → 100644
浏览文件 @
fb73ef7d
import
something
from
'
../apples
'
export
default
()
=>
{
// have to do something with module so it is not tree shaken
console
.
log
(
something
)
return
'
2
'
}
test/integration/next-dynamic/pages/index.js
0 → 100644
浏览文件 @
fb73ef7d
import
dynamic
from
'
next/dynamic
'
import
{
useState
,
useEffect
}
from
'
react
'
const
One
=
dynamic
(()
=>
import
(
'
../components/one
'
))
const
Two
=
dynamic
(()
=>
import
(
'
../components/two
'
))
const
Three
=
dynamic
(()
=>
import
(
'
../components/three
'
))
export
default
()
=>
{
const
[
firstRender
,
setFirstRender
]
=
useState
(
'
the-server-value
'
)
useEffect
(()
=>
{
setFirstRender
(
document
.
getElementById
(
'
foo
'
).
innerHTML
)
},
[])
return
(
<>
<
div
id
=
'
foo
'
>
Index
<
One
/>
<
Two
/>
<
Three
/>
<
/div
>
<
div
id
=
'
first-render
'
>
{
firstRender
}
<
/div
>
<
/
>
)
}
test/integration/next-dynamic/test/index.test.js
0 → 100644
浏览文件 @
fb73ef7d
/* eslint-env jest */
/* global jasmine */
import
webdriver
from
'
next-webdriver
'
import
{
join
}
from
'
path
'
import
{
renderViaHTTP
,
findPort
,
launchApp
,
killApp
,
waitFor
,
runNextCommand
,
nextServer
,
startApp
,
stopApp
}
from
'
next-test-utils
'
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
*
60
*
5
let
app
let
appPort
let
server
const
appDir
=
join
(
__dirname
,
'
../
'
)
function
runTests
()
{
it
(
'
should render server value
'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
appPort
,
'
/
'
)
expect
(
html
).
toMatch
(
/the-server-value/i
)
})
it
(
'
should render dynamic server rendered values on client mount
'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'
/
'
)
await
waitFor
(
5000
)
const
text
=
await
browser
.
elementByCss
(
'
#first-render
'
).
text
()
// Failure case is 'Index<!-- -->3<!-- --><!-- -->'
expect
(
text
).
toBe
(
'
Index<!-- -->1<!-- -->2<!-- -->3
'
)
})
}
describe
(
'
next/dynamic
'
,
()
=>
{
describe
(
'
dev mode
'
,
()
=>
{
beforeAll
(
async
()
=>
{
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
)
})
afterAll
(()
=>
killApp
(
app
))
runTests
(
true
)
})
describe
(
'
production mode
'
,
()
=>
{
beforeAll
(
async
()
=>
{
await
runNextCommand
([
'
build
'
,
appDir
])
app
=
nextServer
({
dir
:
appDir
,
dev
:
false
,
quiet
:
true
})
server
=
await
startApp
(
app
)
appPort
=
server
.
address
().
port
})
afterAll
(()
=>
stopApp
(
server
))
runTests
()
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录