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
474f1e7d
Unverified
Commit
474f1e7d
authored
Oct 25, 2021
by
JJ Kasper
Committed by
GitHub
Oct 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial test trace outputs (#30246)
parent
9d280afb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
17 deletions
+114
-17
build_test_deploy.yml
.github/workflows/build_test_deploy.yml
+9
-0
output.js
packages/next/build/swc/tests/full/example/output.js
+15
-15
run-tests.js
run-tests.js
+14
-2
playwright.ts
test/lib/browsers/playwright.ts
+51
-0
e2e-utils.ts
test/lib/e2e-utils.ts
+2
-0
base.ts
test/lib/next-modes/base.ts
+19
-0
next-webdriver.ts
test/lib/next-webdriver.ts
+4
-0
No files found.
.github/workflows/build_test_deploy.yml
View file @
474f1e7d
...
@@ -171,6 +171,15 @@ jobs:
...
@@ -171,6 +171,15 @@ jobs:
name
:
Run test/e2e (dev)
name
:
Run test/e2e (dev)
if
:
${{needs.build.outputs.docsChange != 'docs only change'}}
if
:
${{needs.build.outputs.docsChange != 'docs only change'}}
-
name
:
Upload test trace
if
:
always()
uses
:
actions/upload-artifact@v2
with
:
name
:
test-trace
retention-days
:
2
path
:
|
test/traces
testProd
:
testProd
:
name
:
Test Production
name
:
Test Production
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
...
...
packages/next/build/swc/tests/full/example/output.js
View file @
474f1e7d
import
a
from
"other"
;
import
a
from
"other"
;
function
_arrayWithHoles
(
b
)
{
function
_arrayWithHoles
(
a
)
{
if
(
Array
.
isArray
(
b
))
return
b
;
if
(
Array
.
isArray
(
a
))
return
a
;
}
}
function
_classCallCheck
(
c
,
d
)
{
function
_classCallCheck
(
a
,
b
)
{
if
(
!
(
c
instanceof
d
))
throw
new
TypeError
(
"Cannot call a class as a function"
);
if
(
!
(
a
instanceof
b
))
throw
new
TypeError
(
"Cannot call a class as a function"
);
}
}
function
_iterableToArrayLimit
(
b
,
e
)
{
function
_iterableToArrayLimit
(
a
,
b
)
{
var
f
=
[],
g
=
!
0
,
h
=
!
1
,
i
=
void
0
;
var
c
=
[],
d
=
!
0
,
e
=
!
1
,
f
=
void
0
;
try
{
try
{
for
(
var
j
,
k
=
b
[
Symbol
.
iterator
]();
!
(
g
=
(
j
=
k
.
next
()).
done
)
&&
(
f
.
push
(
j
.
value
),
!
e
||
f
.
length
!==
e
);
g
=
!
0
);
for
(
var
g
,
h
=
a
[
Symbol
.
iterator
]();
!
(
d
=
(
g
=
h
.
next
()).
done
)
&&
(
c
.
push
(
g
.
value
),
!
b
||
c
.
length
!==
b
);
d
=
!
0
);
}
catch
(
l
)
{
}
catch
(
a
)
{
h
=
!
0
,
i
=
l
;
e
=
!
0
,
f
=
a
;
}
finally
{
}
finally
{
try
{
try
{
g
||
null
==
k
.
return
||
k
.
return
();
d
||
null
==
h
.
return
||
h
.
return
();
}
finally
{
}
finally
{
if
(
h
)
throw
i
;
if
(
e
)
throw
f
;
}
}
}
}
return
f
;
return
c
;
}
}
function
_nonIterableRest
()
{
function
_nonIterableRest
()
{
throw
new
TypeError
(
"Invalid attempt to destructure non-iterable instance"
);
throw
new
TypeError
(
"Invalid attempt to destructure non-iterable instance"
);
}
}
function
_slicedToArray
(
b
,
e
)
{
function
_slicedToArray
(
a
,
b
)
{
return
_arrayWithHoles
(
b
)
||
_iterableToArrayLimit
(
b
,
e
)
||
_nonIterableRest
();
return
_arrayWithHoles
(
a
)
||
_iterableToArrayLimit
(
a
,
b
)
||
_nonIterableRest
();
}
}
var
foo
=
_slicedToArray
(
a
,
1
)[
0
],
Foo
=
function
()
{
var
foo
=
_slicedToArray
(
a
,
1
)[
0
],
Foo
=
function
()
{
"use strict"
;
"use strict"
;
_classCallCheck
(
this
,
Foo
);
_classCallCheck
(
this
,
Foo
);
};
};
export
var
__N_SSG
=
!
0
;
export
var
__N_SSG
=
!
0
;
export
default
function
Home
()
{
export
default
function
a
()
{
return
React
.
createElement
(
"div"
,
null
);
return
React
.
createElement
(
"div"
,
null
);
};
};
run-tests.js
View file @
474f1e7d
...
@@ -250,6 +250,7 @@ async function main() {
...
@@ -250,6 +250,7 @@ async function main() {
...
process
.
env
,
...
process
.
env
,
// run tests in headless mode by default
// run tests in headless mode by default
HEADLESS
:
'true'
,
HEADLESS
:
'true'
,
TRACE_PLAYWRIGHT
:
'true'
,
...(
usePolling
...(
usePolling
?
{
?
{
// Events can be finicky in CI. This switches to a more
// Events can be finicky in CI. This switches to a more
...
@@ -274,7 +275,7 @@ async function main() {
...
@@ -274,7 +275,7 @@ async function main() {
children
.
add
(
child
)
children
.
add
(
child
)
child
.
on
(
'exit'
,
(
code
)
=>
{
child
.
on
(
'exit'
,
async
(
code
)
=>
{
children
.
delete
(
child
)
children
.
delete
(
child
)
if
(
code
)
{
if
(
code
)
{
if
(
isFinalRun
&&
hideOutput
)
{
if
(
isFinalRun
&&
hideOutput
)
{
...
@@ -297,8 +298,19 @@ async function main() {
...
@@ -297,8 +298,19 @@ async function main() {
}
}
trimmedOutput
.
forEach
((
chunk
)
=>
process
.
stdout
.
write
(
chunk
))
trimmedOutput
.
forEach
((
chunk
)
=>
process
.
stdout
.
write
(
chunk
))
}
}
reject
(
new
Error
(
`failed with code:
${
code
}
`
))
re
turn
re
ject
(
new
Error
(
`failed with code:
${
code
}
`
))
}
}
await
fs
.
remove
(
path
.
join
(
__dirname
,
'test/traces'
,
path
.
relative
(
path
.
join
(
__dirname
,
'test'
),
test
)
.
replace
(
/
\/
/g
,
'-'
)
)
)
.
catch
(()
=>
{})
resolve
(
new
Date
().
getTime
()
-
start
)
resolve
(
new
Date
().
getTime
()
-
start
)
})
})
})
})
...
...
test/lib/browsers/playwright.ts
View file @
474f1e7d
import
{
BrowserInterface
}
from
'./base'
import
{
BrowserInterface
}
from
'./base'
import
fs
from
'fs-extra'
import
{
import
{
chromium
,
chromium
,
webkit
,
webkit
,
...
@@ -8,11 +9,15 @@ import {
...
@@ -8,11 +9,15 @@ import {
Page
,
Page
,
ElementHandle
,
ElementHandle
,
}
from
'playwright-chromium'
}
from
'playwright-chromium'
import
path
from
'path'
let
page
:
Page
let
page
:
Page
let
browser
:
Browser
let
browser
:
Browser
let
context
:
BrowserContext
let
context
:
BrowserContext
let
pageLogs
:
Array
<
{
source
:
string
;
message
:
string
}
>
=
[]
let
pageLogs
:
Array
<
{
source
:
string
;
message
:
string
}
>
=
[]
let
traceStarted
=
false
const
tracePlaywright
=
process
.
env
.
TRACE_PLAYWRIGHT
export
async
function
quit
()
{
export
async
function
quit
()
{
await
context
?.
close
()
await
context
?.
close
()
...
@@ -44,6 +49,24 @@ class Playwright extends BrowserInterface {
...
@@ -44,6 +49,24 @@ class Playwright extends BrowserInterface {
}
}
async
loadPage
(
url
:
string
)
{
async
loadPage
(
url
:
string
)
{
if
(
traceStarted
)
{
const
traceDir
=
path
.
join
(
__dirname
,
'../../traces'
)
const
traceOutputPath
=
path
.
join
(
traceDir
,
`
${
path
.
relative
(
path
.
join
(
__dirname
,
'../../'
),
process
.
env
.
TEST_FILE_PATH
)
.
replace
(
/
\/
/g
,
'-'
)}
`
,
`playwright-
${
encodeURIComponent
(
url
)}
-
${
Date
.
now
()}
.zip`
)
await
fs
.
remove
(
traceOutputPath
)
await
context
.
tracing
.
stop
({
path
:
traceOutputPath
,
})
.
catch
((
err
)
=>
console
.
error
(
'failed to write playwright trace'
,
err
))
}
// clean-up existing pages
// clean-up existing pages
for
(
const
oldPage
of
context
.
pages
())
{
for
(
const
oldPage
of
context
.
pages
())
{
await
oldPage
.
close
()
await
oldPage
.
close
()
...
@@ -61,6 +84,34 @@ class Playwright extends BrowserInterface {
...
@@ -61,6 +84,34 @@ class Playwright extends BrowserInterface {
page
.
on
(
'pageerror'
,
(
error
)
=>
{
page
.
on
(
'pageerror'
,
(
error
)
=>
{
console
.
error
(
'page error'
,
error
)
console
.
error
(
'page error'
,
error
)
})
})
if
(
tracePlaywright
)
{
page
.
on
(
'websocket'
,
(
ws
)
=>
{
page
.
evaluate
(
`console.log('connected to ws at
${
ws
.
url
()}
')`
)
.
catch
(()
=>
{})
ws
.
on
(
'close'
,
()
=>
page
.
evaluate
(
`console.log('closed websocket
${
ws
.
url
()}
')`
)
.
catch
(()
=>
{})
)
ws
.
on
(
'framereceived'
,
(
frame
)
=>
{
if
(
!
frame
.
payload
.
includes
(
'pong'
))
{
page
.
evaluate
(
`console.log('received ws message
${
frame
.
payload
}
')`
)
.
catch
(()
=>
{})
}
})
})
}
if
(
tracePlaywright
)
{
await
context
.
tracing
.
start
({
screenshots
:
true
,
snapshots
:
true
,
})
traceStarted
=
true
}
await
page
.
goto
(
url
,
{
waitUntil
:
'load'
})
await
page
.
goto
(
url
,
{
waitUntil
:
'load'
})
}
}
...
...
test/lib/e2e-utils.ts
View file @
474f1e7d
...
@@ -8,6 +8,8 @@ import { NextStartInstance } from './next-modes/next-start'
...
@@ -8,6 +8,8 @@ import { NextStartInstance } from './next-modes/next-start'
const
testFile
=
module
.
parent
.
filename
const
testFile
=
module
.
parent
.
filename
const
testsFolder
=
path
.
join
(
__dirname
,
'..'
)
const
testsFolder
=
path
.
join
(
__dirname
,
'..'
)
process
.
env
.
TEST_FILE_PATH
=
testFile
let
testMode
=
process
.
env
.
NEXT_TEST_MODE
let
testMode
=
process
.
env
.
NEXT_TEST_MODE
if
(
!
testFile
.
match
(
/
\.
test
\.(
js|tsx
?)
/
))
{
if
(
!
testFile
.
match
(
/
\.
test
\.(
js|tsx
?)
/
))
{
...
...
test/lib/next-modes/base.ts
View file @
474f1e7d
...
@@ -160,6 +160,25 @@ export class NextInstance {
...
@@ -160,6 +160,25 @@ export class NextInstance {
this
.
emit
(
'destroy'
,
[])
this
.
emit
(
'destroy'
,
[])
await
this
.
stop
()
await
this
.
stop
()
if
(
process
.
env
.
TRACE_PLAYWRIGHT
)
{
await
fs
.
copy
(
path
.
join
(
this
.
testDir
,
'.next/trace'
),
path
.
join
(
__dirname
,
'../../traces'
,
`
${
path
.
relative
(
path
.
join
(
__dirname
,
'../../'
),
process
.
env
.
TEST_FILE_PATH
)
.
replace
(
/
\/
/g
,
'-'
)}
`
,
`next-trace`
)
)
.
catch
(()
=>
{})
}
if
(
!
process
.
env
.
NEXT_TEST_SKIP_CLEANUP
)
{
if
(
!
process
.
env
.
NEXT_TEST_SKIP_CLEANUP
)
{
await
fs
.
remove
(
this
.
testDir
)
await
fs
.
remove
(
this
.
testDir
)
}
}
...
...
test/lib/next-webdriver.ts
View file @
474f1e7d
...
@@ -2,6 +2,10 @@ import { getFullUrl } from 'next-test-utils'
...
@@ -2,6 +2,10 @@ import { getFullUrl } from 'next-test-utils'
import
os
from
'os'
import
os
from
'os'
import
{
BrowserInterface
}
from
'./browsers/base'
import
{
BrowserInterface
}
from
'./browsers/base'
if
(
!
process
.
env
.
TEST_FILE_PATH
)
{
process
.
env
.
TEST_FILE_PATH
=
module
.
parent
.
filename
}
let
deviceIP
:
string
let
deviceIP
:
string
const
isBrowserStack
=
!!
process
.
env
.
BROWSERSTACK
const
isBrowserStack
=
!!
process
.
env
.
BROWSERSTACK
;(
global
as
any
).
browserName
=
process
.
env
.
BROWSER_NAME
||
'chrome'
;(
global
as
any
).
browserName
=
process
.
env
.
BROWSER_NAME
||
'chrome'
...
...
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