@naturalcycles/dev-lib 12.20.1 → 12.21.1

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.
@@ -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
- await (0, exec_1.execWithArgs)('jest', (0, js_lib_1._uniq)(args), {
110
- env,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "12.20.1",
3
+ "version": "12.21.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",
@@ -49,7 +49,7 @@
49
49
  "eslint-plugin-jsdoc": "^39.1.0",
50
50
  "eslint-plugin-unicorn": "^42.0.0",
51
51
  "eslint-plugin-unused-imports": "^2.0.0",
52
- "eslint-plugin-vue": "^8.0.1",
52
+ "eslint-plugin-vue": "^9.0.0",
53
53
  "execa": "^5.0.0",
54
54
  "fs-extra": "^10.0.0",
55
55
  "husky": "^8.0.1",
@@ -59,7 +59,7 @@
59
59
  "prettier": "^2.0.4",
60
60
  "stylelint": "^14.0.0",
61
61
  "stylelint-config-prettier": "^9.0.3",
62
- "stylelint-config-standard-scss": "^3.0.0",
62
+ "stylelint-config-standard-scss": "^4.0.0",
63
63
  "timekeeper": "^2.2.0",
64
64
  "ts-jest": "^28.0.0",
65
65
  "typescript": "^4.0.2",
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.