@naturalcycles/dev-lib 12.20.2 → 12.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util/jest.util.js +15 -4
- package/package.json +1 -1
- package/readme.md +11 -0
package/dist/util/jest.util.js
CHANGED
|
@@ -41,7 +41,7 @@ async function runJest(opt = {}) {
|
|
|
41
41
|
console.log((0, colors_1.dimGrey)(`node_modules/${(0, colors_1.white)('jest')} not found, skipping tests`));
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
const { CI, TZ = 'UTC', APP_ENV, JEST_NO_ALPHABETIC, NODE_OPTIONS } = process.env;
|
|
44
|
+
const { CI, TZ = 'UTC', APP_ENV, JEST_NO_ALPHABETIC, JEST_SHARDS, NODE_OPTIONS } = process.env;
|
|
45
45
|
const { integration, manual, leaks } = opt;
|
|
46
46
|
const processArgs = process.argv.slice(2);
|
|
47
47
|
let jestConfig;
|
|
@@ -106,8 +106,19 @@ async function runJest(opt = {}) {
|
|
|
106
106
|
else {
|
|
107
107
|
console.log(`${(0, colors_1.dimGrey)('NODE_OPTIONS are not defined')}`);
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
if (JEST_SHARDS) {
|
|
110
|
+
const totalShards = Number(JEST_SHARDS);
|
|
111
|
+
const shards = (0, js_lib_1._range)(1, totalShards + 1);
|
|
112
|
+
for await (const shard of shards) {
|
|
113
|
+
await (0, exec_1.execWithArgs)('jest', (0, js_lib_1._uniq)([...args, `--shard=${shard}/${totalShards}`]), {
|
|
114
|
+
env,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
await (0, exec_1.execWithArgs)('jest', (0, js_lib_1._uniq)(args), {
|
|
120
|
+
env,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
112
123
|
}
|
|
113
124
|
exports.runJest = runJest;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -125,6 +125,17 @@ For manual tests:
|
|
|
125
125
|
pre-defined sequencer file that sorts all filenames alphabetically). Set `JEST_NO_ALPHABETIC` env
|
|
126
126
|
variable to disable it.
|
|
127
127
|
|
|
128
|
+
##### Shard support (experimental)
|
|
129
|
+
|
|
130
|
+
Jest 28 introduced [--shard](https://jestjs.io/docs/cli#--shard) feature.
|
|
131
|
+
|
|
132
|
+
Set `JEST_SHARDS` environment variable (e.g `export JEST_SHARDS=3`), so that your `yarn test*`
|
|
133
|
+
commands will automatically split your tests by N number of shards and execute them **one after
|
|
134
|
+
another** (serially, **not** in parallel). Might be helpful to avoid Jest's notorious memory leaks.
|
|
135
|
+
|
|
136
|
+
If you need to execute shards **in parallel**, you can follow e.g
|
|
137
|
+
[this instruction](https://medium.com/@mfreundlich1/speed-up-your-jest-tests-with-shards-776e9f02f637).
|
|
138
|
+
|
|
128
139
|
#### Lint commands
|
|
129
140
|
|
|
130
141
|
- `lint-all`: runs ESLint, Stylelint, Prettier, in the right order.
|