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
d84f2919
Commit
d84f2919
authored
Jul 16, 2019
by
Lukáš Huvar
Committed by
Joe Haddad
Jul 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests for both async and sync GIP (#7999)
parent
0b496a45
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
_error.tsx
test/integration/typescript/pages/_error.tsx
+1
-1
typescript.js
test/integration/typescript/test/typescript.js
+17
-2
No files found.
test/integration/typescript/pages/_error.tsx
View file @
d84f2919
...
@@ -2,7 +2,7 @@ import { NextPageContext } from 'next'
...
@@ -2,7 +2,7 @@ import { NextPageContext } from 'next'
import
ErrorComponent
from
'next/error'
import
ErrorComponent
from
'next/error'
class
CustomError
extends
ErrorComponent
{
class
CustomError
extends
ErrorComponent
{
static
async
getInitialProps
({
res
}:
NextPageContext
)
{
static
getInitialProps
({
res
}:
NextPageContext
)
{
const
statusCode
=
500
const
statusCode
=
500
return
{
statusCode
,
title
:
'CustomError'
}
return
{
statusCode
,
title
:
'CustomError'
}
}
}
...
...
test/integration/typescript/test/typescript.js
View file @
d84f2919
/* eslint-env jest */
/* eslint-env jest */
import
{
join
}
from
'path'
import
{
join
}
from
'path'
import
cheerio
from
'cheerio'
import
cheerio
from
'cheerio'
import
{
runNextCommand
}
from
'next-test-utils'
import
{
runNextCommand
,
File
}
from
'next-test-utils'
const
appDir
=
join
(
__dirname
,
'../'
)
const
appDir
=
join
(
__dirname
,
'../'
)
...
@@ -17,7 +17,22 @@ export default (context, render) => {
...
@@ -17,7 +17,22 @@ export default (context, render) => {
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Hello World/
)
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Hello World/
)
})
})
it
(
'Should compile the app'
,
async
()
=>
{
it
(
'should compile the app'
,
async
()
=>
{
const
output
=
await
runNextCommand
([
'build'
,
appDir
],
{
stdout
:
true
})
expect
(
output
.
stdout
).
toMatch
(
/Compiled successfully/
)
})
})
describe
(
'should compile with different types'
,
()
=>
{
const
nextConfig
=
new
File
(
join
(
appDir
,
'pages/_error.tsx'
))
beforeEach
(()
=>
{
nextConfig
.
replace
(
'static '
,
'static async '
)
})
afterEach
(()
=>
{
nextConfig
.
restore
()
})
it
(
'should compile async getInitialProps for _error'
,
async
()
=>
{
const
output
=
await
runNextCommand
([
'build'
,
appDir
],
{
stdout
:
true
})
const
output
=
await
runNextCommand
([
'build'
,
appDir
],
{
stdout
:
true
})
expect
(
output
.
stdout
).
toMatch
(
/Compiled successfully/
)
expect
(
output
.
stdout
).
toMatch
(
/Compiled successfully/
)
})
})
...
...
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