@@ -5,9 +5,9 @@ const CURRENT_NODE_VERSION = process.version.replace('v', '').split('.')[0];
5
5
6
6
// We run ember tests in their own job.
7
7
const DEFAULT_SKIP_TESTS_PACKAGES = [ '@sentry/ember' ] ;
8
+
8
9
// These packages don't support Node 8 for syntax or dependency reasons.
9
10
const NODE_8_SKIP_TESTS_PACKAGES = [
10
- ...DEFAULT_SKIP_TESTS_PACKAGES ,
11
11
'@sentry-internal/eslint-plugin-sdk' ,
12
12
'@sentry/react' ,
13
13
'@sentry/wasm' ,
@@ -20,6 +20,26 @@ const NODE_8_SKIP_TESTS_PACKAGES = [
20
20
'@sentry/replay' ,
21
21
] ;
22
22
23
+ // These can be skipped when running tests in different Node environments.
24
+ const SKIP_BROWSER_TESTS_PACKAGES = [
25
+ '@sentry/browser' ,
26
+ '@sentry/vue' ,
27
+ '@sentry/react' ,
28
+ '@sentry/angular' ,
29
+ '@sentry/svelte' ,
30
+ '@sentry/replay' ,
31
+ ] ;
32
+
33
+ // These can be skipped when running tests independently of the Node version.
34
+ const SKIP_NODE_TESTS_PACKAGES = [
35
+ '@sentry/node' ,
36
+ '@sentry/opentelemetry-node' ,
37
+ '@sentry/serverless' ,
38
+ '@sentry/nextjs' ,
39
+ '@sentry/remix' ,
40
+ '@sentry/gatsby' ,
41
+ ] ;
42
+
23
43
// We have to downgrade some of our dependencies in order to run tests in Node 8 and 10.
24
44
const NODE_8_LEGACY_DEPENDENCIES = [
25
45
@@ -91,13 +111,10 @@ const es6ifyTestTSConfig = (pkg: string): void => {
91
111
} ;
92
112
93
113
/**
94
- * Skip tests which don't apply to Node and therefore don't need to run in older Node versions.
95
- *
96
- * TODO We're foreced to skip these tests for compatibility reasons (right now this function only gets called in Node
97
- * 8), but we could be skipping a lot more tests in Node 8-14 - anything where compatibility with different Node
98
- * versions is irrelevant - and only running them in Node 16.
114
+ * Skip tests which don't run in Node 8.
115
+ * We're forced to skip these tests for compatibility reasons.
99
116
*/
100
- function skipNonNodeTests ( ) : void {
117
+ function skipNodeV8Tests ( ) : void {
101
118
run ( 'rm -rf packages/tracing/test/browser' ) ;
102
119
}
103
120
@@ -113,29 +130,37 @@ function runWithIgnores(skipPackages: string[] = []): void {
113
130
* Run the tests, accounting for compatibility problems in older versions of Node.
114
131
*/
115
132
function runTests ( ) : void {
116
- if ( CURRENT_NODE_VERSION === '8' ) {
117
- installLegacyDeps ( NODE_8_LEGACY_DEPENDENCIES ) ;
118
- // TODO Right now, this just skips incompatible tests, but it could be skipping more (hence the aspirational name),
119
- // and not just in Node 8. See `skipNonNodeTests`'s docstring.
120
- skipNonNodeTests ( ) ;
121
- es6ifyTestTSConfig ( 'utils' ) ;
122
- runWithIgnores ( NODE_8_SKIP_TESTS_PACKAGES ) ;
123
- }
124
- //
125
- else if ( CURRENT_NODE_VERSION === '10' ) {
126
- installLegacyDeps ( NODE_10_LEGACY_DEPENDENCIES ) ;
127
- es6ifyTestTSConfig ( 'utils' ) ;
128
- runWithIgnores ( NODE_10_SKIP_TESTS_PACKAGES ) ;
133
+ const ignores = new Set < string > ( ) ;
134
+
135
+ DEFAULT_SKIP_TESTS_PACKAGES . forEach ( dep => ignores . add ( dep ) ) ;
136
+
137
+ if ( process . env . TESTS_SKIP === 'browser' ) {
138
+ SKIP_BROWSER_TESTS_PACKAGES . forEach ( dep => ignores . add ( dep ) ) ;
129
139
}
130
- //
131
- else if ( CURRENT_NODE_VERSION === '12' ) {
132
- es6ifyTestTSConfig ( 'utils' ) ;
133
- runWithIgnores ( NODE_12_SKIP_TESTS_PACKAGES ) ;
140
+
141
+ if ( process . env . TESTS_SKIP === 'node' ) {
142
+ SKIP_NODE_TESTS_PACKAGES . forEach ( dep => ignores . add ( dep ) ) ;
134
143
}
135
- //
136
- else {
137
- runWithIgnores ( DEFAULT_SKIP_TESTS_PACKAGES ) ;
144
+
145
+ switch ( CURRENT_NODE_VERSION ) {
146
+ case '8' :
147
+ NODE_8_SKIP_TESTS_PACKAGES . forEach ( dep => ignores . add ( dep ) ) ;
148
+ installLegacyDeps ( NODE_8_LEGACY_DEPENDENCIES ) ;
149
+ skipNodeV8Tests ( ) ;
150
+ es6ifyTestTSConfig ( 'utils' ) ;
151
+ break ;
152
+ case '10' :
153
+ NODE_10_SKIP_TESTS_PACKAGES . forEach ( dep => ignores . add ( dep ) ) ;
154
+ installLegacyDeps ( NODE_10_LEGACY_DEPENDENCIES ) ;
155
+ es6ifyTestTSConfig ( 'utils' ) ;
156
+ break ;
157
+ case '12' :
158
+ NODE_12_SKIP_TESTS_PACKAGES . forEach ( dep => ignores . add ( dep ) ) ;
159
+ es6ifyTestTSConfig ( 'utils' ) ;
160
+ break ;
138
161
}
162
+
163
+ runWithIgnores ( Array . from ( ignores ) ) ;
139
164
}
140
165
141
166
runTests ( ) ;
0 commit comments