Skip to content

Commit 6b08762

Browse files
committed
relax definitions tests matrix
1 parent a4ef5de commit 6b08762

File tree

4 files changed

+46
-33
lines changed

4 files changed

+46
-33
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
node-version: 25
3131
cache: npm
3232
- run: npm run prepare-monorepo
33-
- run: npx run-s build-types test-type-definitions-all
33+
- run: npx run-s build-types test-type-definitions-ci
3434

3535
karma:
3636
runs-on: windows-2022

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ If you have no access to all required browsers / versions of browsers, use [Sauc
8585
```
8686
- To test the types, run the command:
8787
```sh
88-
npm run test-type-definitions
88+
npm run test-type-definitions-all
8989
```
9090

9191
## Style and standards

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"lint": "run-s prepare lint-raw",
4343
"lint-raw": "run-s build-types test-eslint bundle-package test-publint",
4444
"test": "run-s prepare test-raw",
45-
"test-raw": "run-s lint-raw test-type-definitions types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check",
45+
"test-raw": "run-s lint-raw test-type-definitions-smoke types-coverage bundle-tests test-unit test-promises test-entries test-compat-data test-compat-tools test-builder test-babel-plugin check",
4646
"test-eslint": "npm run zxi time tests/eslint/runner.mjs",
4747
"test-publint": "npm run zxi time tests/publint/runner.mjs",
4848
"test-unit": "run-s test-unit-karma test-unit-node test-unit-bun",
@@ -56,8 +56,9 @@
5656
"test-compat-data": "npm run zxi tests/compat-data/index.mjs",
5757
"test-compat-tools": "npm run zxi tests/compat-tools/index.mjs",
5858
"test-templates": "npm run zxi tests/templates/templates.mjs",
59-
"test-type-definitions": "npm run zxi time cd tests/type-definitions/runner.mjs",
60-
"test-type-definitions-all": "ALL_TYPE_DEFINITIONS_TESTS=1 npm run zxi time cd tests/type-definitions/runner.mjs",
59+
"test-type-definitions-all": "TYPE_DEFINITIONS_TESTS=ALL npm run zxi time cd tests/type-definitions/runner.mjs",
60+
"test-type-definitions-ci": "TYPE_DEFINITIONS_TESTS=CI npm run zxi time cd tests/type-definitions/runner.mjs",
61+
"test-type-definitions-smoke": "TYPE_DEFINITIONS_TESTS=SMOKE npm run zxi time cd tests/type-definitions/runner.mjs",
6162
"test262": "npm run zxi time cd tests/test262/runner.mjs",
6263
"types-coverage": "npm run zxi tests/type-definitions/coverage.mjs",
6364
"refresh": "UPDATE_DEPENDENCIES=1 npm run prepare-monorepo && npm run test-raw",

tests/type-definitions/runner.mjs

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import { fs } from 'zx';
33

44
const { mkdir, rm, writeJson } = fs;
55

6-
const ALL_TESTS = process.env.ALL_TYPE_DEFINITIONS_TESTS === '1';
6+
const { TYPE_DEFINITIONS_TESTS } = process.env;
7+
8+
if (!['ALL', 'CI', 'SMOKE'].includes(TYPE_DEFINITIONS_TESTS)) {
9+
throw new Error('Incorrect or lack of TYPE_DEFINITIONS_TESTS');
10+
}
11+
12+
const ALL_TESTS = TYPE_DEFINITIONS_TESTS === 'ALL';
13+
const CI_TESTS = TYPE_DEFINITIONS_TESTS === 'CI';
714
const NUM_CPUS = cpus().length;
815
const TMP_DIR = './tmp/';
916

@@ -13,23 +20,25 @@ const ES_TARGETS = [
1320
'es6',
1421
];
1522

16-
const TYPE_SCRIPT_VERSIONS = ALL_TESTS ? [
23+
const DEFAULT_TYPE_SCRIPT_VERSION = '5.9';
24+
25+
const TYPE_SCRIPT_VERSIONS = [DEFAULT_TYPE_SCRIPT_VERSION, ...ALL_TESTS ? [
1726
'6.0.0-beta',
18-
'5.9',
1927
'5.8',
2028
'5.7',
2129
'5.6',
2230
// '5.5', // fails with node types: Named property 'next' of types 'AsyncIterator<T, TReturn, TNext>' and 'AsyncIteratorObject<T, TReturn, TNext>' are not identical.
2331
// '5.4',
2432
// '5.3',
2533
// '5.2',
26-
] : [
27-
'5.9',
34+
] : CI_TESTS ? [
35+
'6.0.0-beta',
2836
'5.6',
29-
];
37+
] : [
38+
// empty
39+
]];
3040

3141
const ENVIRONMENTS = ALL_TESTS ? [
32-
null,
3342
'@types/node@25',
3443
'@types/node@24',
3544
'@types/node@22',
@@ -39,21 +48,24 @@ const ENVIRONMENTS = ALL_TESTS ? [
3948
// '@types/node@15', // fails
4049
// '@types/bun@latest', // ArrayBuffer.resize signature incorrect. Return type ArrayBuffer instead of void.
4150
// '@types/deno@latest', // fails
51+
] : CI_TESTS ? [
52+
'@types/node@25',
53+
'@types/node@24',
54+
'@types/node@22',
55+
'@types/node@16',
4256
] : [
43-
null,
4457
'@types/node@25',
4558
];
4659

60+
const LIBS = [
61+
'dom',
62+
];
63+
4764
const CORE_JS_MODES = [
4865
'global',
4966
'pure',
5067
];
5168

52-
const LIBS = [
53-
'dom',
54-
null,
55-
];
56-
5769
const TARGET_RULES = {
5870
es6: '**/*es2018*test.ts',
5971
};
@@ -79,7 +91,7 @@ async function runTasksInParallel() {
7991
}));
8092
}
8193

82-
async function runTask({ cwd, ts, config, args = [] }) {
94+
async function runTask({ cwd, ts = DEFAULT_TYPE_SCRIPT_VERSION, config, args = [] }) {
8395
const task = $({ cwd, verbose: false })`npx --package typescript@${ ts } tsc --project ${ config } ${ args }`;
8496
// eslint-disable-next-line no-underscore-dangle -- third-party code
8597
const { cmd } = task._snapshot;
@@ -98,8 +110,8 @@ function * buildTasks() {
98110
for (const mode of CORE_JS_MODES) {
99111
for (const target of ES_TARGETS) {
100112
for (const ts of TYPE_SCRIPT_VERSIONS) {
101-
for (const env of ENVIRONMENTS) {
102-
for (const lib of LIBS) {
113+
for (const env of [null, ...ENVIRONMENTS]) {
114+
for (const lib of [null, ...LIBS]) {
103115
const tsConfigPostfix = `${ TARGET_RULES[target] ? `.${ target }` : '' }${ LIB_RULES[lib] ? `.${ lib }` : '' }`;
104116
const config = env ? `./tsconfig.${ mode }${ tsConfigPostfix }.json` : `${ mode }/tsconfig${ tsConfigPostfix }.json`;
105117
const libWithTarget = lib ? `${ target },${ lib }` : target;
@@ -156,18 +168,18 @@ async function prepareEnvironments() {
156168
}
157169

158170
const tasks = [
159-
{ ts: '5.9', config: 'tools/tsconfig.json' },
160-
{ ts: '5.9', config: 'templates/tsconfig.json' },
161-
{ ts: '5.9', config: 'templates/tsconfig.require.json' },
162-
{ ts: '5.9', config: 'entries/full/tsconfig.json' },
163-
{ ts: '5.9', config: 'entries/actual/tsconfig.json' },
164-
{ ts: '5.9', config: 'entries/stable/tsconfig.json' },
165-
{ ts: '5.9', config: 'entries/es/tsconfig.json' },
166-
{ ts: '5.9', config: 'entries/proposals/tsconfig.json' },
167-
{ ts: '5.9', config: 'entries/global-imports/tsconfig.json' },
168-
{ ts: '5.9', config: 'entries/pure-imports/tsconfig.json' },
169-
{ ts: '5.9', config: 'entries/configurator/tsconfig.json' },
170-
{ ts: '5.9', config: 'entries/pure-pollutions/tsconfig.json' },
171+
{ config: 'tools/tsconfig.json' },
172+
{ config: 'templates/tsconfig.json' },
173+
{ config: 'templates/tsconfig.require.json' },
174+
{ config: 'entries/full/tsconfig.json' },
175+
{ config: 'entries/actual/tsconfig.json' },
176+
{ config: 'entries/stable/tsconfig.json' },
177+
{ config: 'entries/es/tsconfig.json' },
178+
{ config: 'entries/proposals/tsconfig.json' },
179+
{ config: 'entries/global-imports/tsconfig.json' },
180+
{ config: 'entries/pure-imports/tsconfig.json' },
181+
{ config: 'entries/configurator/tsconfig.json' },
182+
{ config: 'entries/pure-pollutions/tsconfig.json' },
171183
...buildTasks(),
172184
];
173185

0 commit comments

Comments
 (0)