FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TypeScript/scripts/browserIntegrationTest.mjs at main · strager/TypeScript · GitHub
strager
/
TypeScript
Public
forked from
microsoft/TypeScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TypeScript
/
scripts
/
browserIntegrationTest.mjs
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (42 loc) · 1.47 KB
Breadcrumbs
TypeScript
/
scripts
/
browserIntegrationTest.mjs
Copy path
File metadata and controls
50 lines (42 loc) · 1.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import
chalk
from
"chalk"
;
import
{
readFileSync
}
from
"fs"
;
import
{
join
}
from
"path"
;
let
playwright
;
try
{
//
@ts
-ignore-error
playwright
=
await
import
(
"playwright"
)
;
}
catch
(
error
)
{
throw
new
Error
(
"Playwright is expected to be installed manually before running this script"
)
;
}
// Turning this on will leave the Chromium browser open, giving you the
// chance to open up the web inspector.
const
debugging
=
false
;
/**
@type
{
["chromium", "firefox"]
} */
const
browsers
=
[
"chromium"
,
"firefox"
]
;
for
(
const
browserType
of
browsers
)
{
const
browser
=
await
playwright
[
browserType
]
.
launch
(
{
headless
:
!
debugging
}
)
;
const
context
=
await
browser
.
newContext
(
)
;
const
page
=
await
context
.
newPage
(
)
;
/**
@type
{
(err: Error) => void
} */
const
errorCaught
=
err
=>
{
console
.
error
(
chalk
.
red
(
"There was an error running built/typescript.js in "
+
browserType
)
)
;
console
.
log
(
err
.
toString
(
)
)
;
process
.
exitCode
=
1
;
}
;
//
@ts
-ignore-error
page
.
on
(
"error"
,
errorCaught
)
;
page
.
on
(
"pageerror"
,
errorCaught
)
;
await
page
.
setContent
(
`
<html>
<script>
${
readFileSync
(
join
(
"built"
,
"local"
,
"typescript.js"
)
,
"utf8"
)
}
</script>
</html>
`
)
;
if
(
!
debugging
)
{
await
browser
.
close
(
)
;
}
else
{
console
.
log
(
"Not closing the browser, you'll need to exit the process in your terminal manually"
)
;
}
console
.
log
(
`
${
browserType
}
:+1:`
)
;
}
Back
|
FazBrowse Home
|
New Git URL