Skip to content

Commit 733e5ae

Browse files
committed
refactor node unit tests
1 parent 4f6820f commit 733e5ae

File tree

3 files changed

+16
-47
lines changed

3 files changed

+16
-47
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,9 @@ jobs:
423423
key: ${{ env.BUILD_CACHE_KEY }}
424424
- name: Run tests
425425
env:
426-
NEEDS_OLD_TS_NODE: ${{ matrix.node == 8 }}
427-
NEEDS_OLD_LERNA: ${{ matrix.node > 8 && matrix.node < 14 }}
426+
NODE_VERSION: ${{ matrix.node }}
428427
run: |
429-
[[ $NEEDS_OLD_TS_NODE == true ]] && yarn add --dev --ignore-engines --ignore-scripts --ignore-workspace-root-check [email protected] [email protected]
430-
[[ $NEEDS_OLD_LERNA == true ]] && yarn add --dev --no-lockfile --ignore-workspace-root-check [email protected]
428+
[[ $NODE_VERSION == 8 ]] && yarn add --dev --ignore-engines --ignore-scripts --ignore-workspace-root-check [email protected]
431429
yarn test-ci-node
432430
- name: Compute test coverage
433431
uses: codecov/codecov-action@v3

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
"lint": "lerna run lint",
2424
"lint:eslint": "lerna run lint:eslint",
2525
"postpublish": "lerna run --stream --concurrency 1 postpublish",
26-
"test": "lerna run --ignore @sentry-internal/browser-integration-tests --ignore @sentry-internal/node-integration-tests test",
27-
"test-ci": "ts-node ./scripts/test.ts",
28-
"test-ci-browser": "cross-env TESTS_SKIP=node ts-node ./scripts/test.ts",
29-
"test-ci-node": "cross-env TESTS_SKIP=browser ts-node ./scripts/test.ts",
26+
"test": "lerna run --ignore @sentry-internal/* test",
27+
"test-ci-browser": "lerna run test --ignore \"@sentry/{node,opentelemetry-node,serverless,nextjs,remix,gatsby}\" --ignore @sentry-internal/*",
28+
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts",
3029
"postinstall": "patch-package"
3130
},
3231
"volta": {

scripts/test.ts renamed to scripts/node-unit-tests.ts

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,9 @@ import * as fs from 'fs';
33

44
const CURRENT_NODE_VERSION = process.version.replace('v', '').split('.')[0];
55

6-
// We run ember tests in their own job.
7-
const DEFAULT_SKIP_TESTS_PACKAGES = ['@sentry/ember'];
8-
9-
// These packages don't support Node 8 for syntax or dependency reasons.
10-
const NODE_8_SKIP_TESTS_PACKAGES = [
6+
const DEFAULT_SKIP_TESTS_PACKAGES = [
117
'@sentry-internal/eslint-plugin-sdk',
12-
'@sentry/react',
13-
'@sentry/wasm',
14-
'@sentry/gatsby',
15-
'@sentry/serverless',
16-
'@sentry/nextjs',
17-
'@sentry/angular',
18-
'@sentry/remix',
19-
'@sentry/svelte', // svelte testing library requires Node >= 10
20-
'@sentry/replay',
21-
];
22-
23-
// These can be skipped when running tests in different Node environments.
24-
const SKIP_BROWSER_TESTS_PACKAGES = [
8+
'@sentry/ember',
259
'@sentry/browser',
2610
'@sentry/vue',
2711
'@sentry/react',
@@ -31,15 +15,8 @@ const SKIP_BROWSER_TESTS_PACKAGES = [
3115
'@sentry/wasm',
3216
];
3317

34-
// These can be skipped when running tests independently of the Node version.
35-
const SKIP_NODE_TESTS_PACKAGES = [
36-
'@sentry/node',
37-
'@sentry/opentelemetry-node',
38-
'@sentry/serverless',
39-
'@sentry/nextjs',
40-
'@sentry/remix',
41-
'@sentry/gatsby',
42-
];
18+
// These packages don't support Node 8 for syntax or dependency reasons.
19+
const NODE_8_SKIP_TESTS_PACKAGES = ['@sentry/gatsby', '@sentry/serverless', '@sentry/nextjs', '@sentry/remix'];
4320

4421
// We have to downgrade some of our dependencies in order to run tests in Node 8 and 10.
4522
const NODE_8_LEGACY_DEPENDENCIES = [
@@ -48,12 +25,14 @@ const NODE_8_LEGACY_DEPENDENCIES = [
4825
4926
5027
28+
5129
];
5230

53-
const NODE_10_SKIP_TESTS_PACKAGES = ['@sentry/remix', '@sentry/replay'];
54-
const NODE_10_LEGACY_DEPENDENCIES = ['[email protected]'];
31+
const NODE_10_SKIP_TESTS_PACKAGES = ['@sentry/remix'];
32+
const NODE_10_LEGACY_DEPENDENCIES = ['[email protected]', '[email protected]'];
5533

5634
const NODE_12_SKIP_TESTS_PACKAGES = ['@sentry/remix'];
35+
const NODE_12_LEGACY_DEPENDENCIES = ['[email protected]'];
5736

5837
type JSONValue = string | number | boolean | null | JSONArray | JSONObject;
5938

@@ -70,8 +49,8 @@ interface TSConfigJSON extends JSONObject {
7049
* Run the given shell command, piping the shell process's `stdin`, `stdout`, and `stderr` to that of the current
7150
* process. Returns contents of `stdout`.
7251
*/
73-
function run(cmd: string, options?: childProcess.ExecSyncOptions) {
74-
return childProcess.execSync(cmd, { stdio: 'inherit', ...options });
52+
function run(cmd: string, options?: childProcess.ExecSyncOptions): void {
53+
childProcess.execSync(cmd, { stdio: 'inherit', ...options });
7554
}
7655

7756
/**
@@ -135,14 +114,6 @@ function runTests(): void {
135114

136115
DEFAULT_SKIP_TESTS_PACKAGES.forEach(dep => ignores.add(dep));
137116

138-
if (process.env.TESTS_SKIP === 'browser') {
139-
SKIP_BROWSER_TESTS_PACKAGES.forEach(dep => ignores.add(dep));
140-
}
141-
142-
if (process.env.TESTS_SKIP === 'node') {
143-
SKIP_NODE_TESTS_PACKAGES.forEach(dep => ignores.add(dep));
144-
}
145-
146117
switch (CURRENT_NODE_VERSION) {
147118
case '8':
148119
NODE_8_SKIP_TESTS_PACKAGES.forEach(dep => ignores.add(dep));
@@ -157,6 +128,7 @@ function runTests(): void {
157128
break;
158129
case '12':
159130
NODE_12_SKIP_TESTS_PACKAGES.forEach(dep => ignores.add(dep));
131+
installLegacyDeps(NODE_12_LEGACY_DEPENDENCIES);
160132
es6ifyTestTSConfig('utils');
161133
break;
162134
}

0 commit comments

Comments
 (0)