FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sentry-javascript/scripts/node-unit-tests.ts at develop · Mause/sentry-javascript · GitHub
Mause
/
sentry-javascript
Public
forked from
getsentry/sentry-javascript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
sentry-javascript
/
scripts
/
node-unit-tests.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
188 lines (167 loc) · 5.26 KB
Breadcrumbs
sentry-javascript
/
scripts
/
node-unit-tests.ts
Copy path
File metadata and controls
188 lines (167 loc) · 5.26 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import
*
as
childProcess
from
'child_process'
;
import
*
as
fs
from
'fs'
;
type
NodeVersion
=
'8'
|
'10'
|
'12'
|
'14'
|
'16'
;
interface
VersionConfig
{
ignoredPackages
:
Array
<
`@${
'sentry'
|
'sentry-internal'
}
/${
string
}
`
>
;
legacyDeps
:
Array
<
`${
string
}
@${
string
}
`
>
;
shouldES6Utils
:
boolean
;
}
const
CURRENT_NODE_VERSION
=
process
.
version
.
replace
(
'v'
,
''
)
.
split
(
'.'
)
[
0
]
as
NodeVersion
;
const
DEFAULT_SKIP_TESTS_PACKAGES
=
[
'@sentry-internal/eslint-plugin-sdk'
,
'@sentry/ember'
,
'@sentry/browser'
,
'@sentry/vue'
,
'@sentry/react'
,
'@sentry/angular'
,
'@sentry/svelte'
,
'@sentry/replay'
,
'@sentry-internal/feedback'
,
'@sentry/wasm'
,
'@sentry/bun'
,
'@sentry/deno'
,
]
;
const
SKIP_TEST_PACKAGES
:
Record
<
NodeVersion
,
VersionConfig
>
=
{
'8'
:
{
ignoredPackages
:
[
'@sentry/gatsby'
,
'@sentry/serverless'
,
'@sentry/nextjs'
,
'@sentry/remix'
,
'@sentry/sveltekit'
,
'@sentry-internal/replay-worker'
,
'@sentry/node-experimental'
,
'@sentry/opentelemetry'
,
'@sentry/vercel-edge'
,
'@sentry/astro'
,
]
,
legacyDeps
:
[
'jsdom@15.x'
,
'jest@25.x'
,
'jest-environment-jsdom@25.x'
,
'jest-environment-node@25.x'
,
'ts-jest@25.x'
,
'lerna@3.13.4'
,
]
,
shouldES6Utils
:
true
,
}
,
'10'
:
{
ignoredPackages
:
[
'@sentry/remix'
,
'@sentry/sveltekit'
,
'@sentry-internal/replay-worker'
,
'@sentry/node-experimental'
,
'@sentry/opentelemetry'
,
'@sentry/vercel-edge'
,
'@sentry/astro'
,
]
,
legacyDeps
:
[
'jsdom@16.x'
,
'lerna@3.13.4'
]
,
shouldES6Utils
:
true
,
}
,
'12'
:
{
ignoredPackages
:
[
'@sentry/remix'
,
'@sentry/sveltekit'
,
'@sentry/node-experimental'
,
'@sentry/opentelemetry'
,
'@sentry/vercel-edge'
,
'@sentry/astro'
,
]
,
legacyDeps
:
[
'lerna@3.13.4'
]
,
shouldES6Utils
:
true
,
}
,
'14'
:
{
ignoredPackages
:
[
'@sentry/sveltekit'
,
'@sentry/vercel-edge'
,
'@sentry/astro'
]
,
legacyDeps
:
[
]
,
shouldES6Utils
:
false
,
}
,
'16'
:
{
ignoredPackages
:
[
'@sentry/vercel-edge'
,
'@sentry/astro'
]
,
legacyDeps
:
[
]
,
shouldES6Utils
:
false
,
}
,
}
;
type
JSONValue
=
string
|
number
|
boolean
|
null
|
JSONArray
|
JSONObject
;
type
JSONObject
=
{
[
key
:
string
]
:
JSONValue
;
}
;
type
JSONArray
=
Array
<
JSONValue
>
;
interface
TSConfigJSON
extends
JSONObject
{
compilerOptions
:
{
lib
:
string
[
]
;
target
:
string
}
;
}
/**
* Run the given shell command, piping the shell process's `stdin`, `stdout`, and `stderr` to that of the current
* process. Returns contents of `stdout`.
*/
function
run
(
cmd
:
string
,
options
?:
childProcess
.
ExecSyncOptions
)
:
void
{
childProcess
.
execSync
(
cmd
,
{
stdio
:
'inherit'
,
...
options
}
)
;
}
/**
* Install the given legacy dependencies, for compatibility with tests run in older versions of Node.
*/
function
installLegacyDeps
(
legacyDeps
:
string
[
]
=
[
]
)
:
void
{
// Ignoring engines and scripts lets us get away with having incompatible things installed for SDK packages we're not
// testing in the current node version, and ignoring the root check lets us install things at the repo root.
run
(
`yarn add --dev --ignore-engines --ignore-scripts --ignore-workspace-root-check
${
legacyDeps
.
join
(
' '
)
}
`
)
;
}
/**
* Modify a json file on disk.
*
*
@param
filepath The path to the file to be modified
*
@param
transformer A function which takes the JSON data as input and returns a mutated version. It may mutate the
* JSON data in place, but it isn't required to do so.
*/
export
function
modifyJSONFile
<
T
extends
JSONObject
>
(
filepath
:
string
,
transformer
:
(
json
:
T
)
=>
T
)
:
void
{
const
fileContents
=
fs
.
readFileSync
(
filepath
)
.
toString
(
)
// get rid of comments, which the `jsonc` format allows, but which will crash `JSON.parse`
.
replace
(
/
\/
\/
.
*
\n
/
g
,
''
)
;
const
json
=
JSON
.
parse
(
fileContents
)
;
const
newJSON
=
transformer
(
json
)
;
fs
.
writeFileSync
(
filepath
,
JSON
.
stringify
(
newJSON
,
null
,
2
)
)
;
}
const
es6ifyTestTSConfig
=
(
pkg
:
string
)
:
void
=>
{
const
filepath
=
`packages/
${
pkg
}
/tsconfig.test.json`
;
const
transformer
=
(
tsconfig
:
TSConfigJSON
)
:
TSConfigJSON
=>
{
tsconfig
.
compilerOptions
.
target
=
'es6'
;
return
tsconfig
;
}
;
modifyJSONFile
(
filepath
,
transformer
)
;
}
;
/**
* Skip tests which don't run in Node 8.
* We're forced to skip these tests for compatibility reasons.
*/
function
skipNodeV8Tests
(
)
:
void
{
run
(
'rm -rf packages/tracing/test/browser'
)
;
}
/**
* Run tests, ignoring the given packages
*/
function
runWithIgnores
(
skipPackages
:
string
[
]
=
[
]
)
:
void
{
const
ignoreFlags
=
skipPackages
.
map
(
dep
=>
`--ignore="
${
dep
}
"`
)
.
join
(
' '
)
;
run
(
`yarn test
${
ignoreFlags
}
`
)
;
}
/**
* Run the tests, accounting for compatibility problems in older versions of Node.
*/
function
runTests
(
)
:
void
{
const
ignores
=
new
Set
<
string
>
(
)
;
DEFAULT_SKIP_TESTS_PACKAGES
.
forEach
(
pkg
=>
ignores
.
add
(
pkg
)
)
;
if
(
CURRENT_NODE_VERSION
===
'8'
)
{
skipNodeV8Tests
(
)
;
}
const
versionConfig
=
SKIP_TEST_PACKAGES
[
CURRENT_NODE_VERSION
]
;
if
(
versionConfig
)
{
versionConfig
.
ignoredPackages
.
forEach
(
dep
=>
ignores
.
add
(
dep
)
)
;
if
(
versionConfig
.
legacyDeps
.
length
>
0
)
{
installLegacyDeps
(
versionConfig
.
legacyDeps
)
;
}
if
(
versionConfig
.
shouldES6Utils
)
{
es6ifyTestTSConfig
(
'utils'
)
;
}
}
runWithIgnores
(
Array
.
from
(
ignores
)
)
;
}
runTests
(
)
;
Back
|
FazBrowse Home
|
New Git URL