@teambit/jest 0.0.881 → 0.0.883

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.
@@ -1,42 +1,32 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.regexp.exec.js");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getRootDirFromConfigPath = getRootDirFromConfigPath;
9
-
10
8
  function _lodash() {
11
9
  const data = require("lodash");
12
-
13
10
  _lodash = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  function _path() {
21
16
  const data = require("path");
22
-
23
17
  _path = function () {
24
18
  return data;
25
19
  };
26
-
27
20
  return data;
28
21
  }
29
-
30
22
  function getRootDirFromConfigPath(configPath) {
31
23
  const splitted = configPath.split('node_modules');
32
24
  const last = splitted[splitted.length - 1];
33
25
  const lastSplitted = (0, _lodash().compact)(last.split(_path().sep));
34
26
  let lastModule = lastSplitted[0];
35
-
36
27
  if (lastSplitted[0].startsWith('@')) {
37
28
  lastModule = (0, _path().join)(lastSplitted[0], lastSplitted[1]);
38
29
  }
39
-
40
30
  splitted[splitted.length - 1] = `${_path().sep}${lastModule}`;
41
31
  const final = splitted.join('node_modules');
42
32
  return final;
@@ -1 +1 @@
1
- {"version":3,"names":["getRootDirFromConfigPath","configPath","splitted","split","last","length","lastSplitted","compact","sep","lastModule","startsWith","join","final"],"sources":["calc-root-dir.ts"],"sourcesContent":["import { compact } from 'lodash';\nimport { join, sep } from 'path';\n\nexport function getRootDirFromConfigPath(configPath: string): string {\n const splitted = configPath.split('node_modules');\n const last = splitted[splitted.length - 1];\n const lastSplitted = compact(last.split(sep));\n let lastModule = lastSplitted[0];\n if (lastSplitted[0].startsWith('@')) {\n lastModule = join(lastSplitted[0], lastSplitted[1]);\n }\n splitted[splitted.length - 1] = `${sep}${lastModule}`;\n const final = splitted.join('node_modules');\n return final;\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,SAASA,wBAAT,CAAkCC,UAAlC,EAA8D;EACnE,MAAMC,QAAQ,GAAGD,UAAU,CAACE,KAAX,CAAiB,cAAjB,CAAjB;EACA,MAAMC,IAAI,GAAGF,QAAQ,CAACA,QAAQ,CAACG,MAAT,GAAkB,CAAnB,CAArB;EACA,MAAMC,YAAY,GAAG,IAAAC,iBAAA,EAAQH,IAAI,CAACD,KAAL,CAAWK,WAAX,CAAR,CAArB;EACA,IAAIC,UAAU,GAAGH,YAAY,CAAC,CAAD,CAA7B;;EACA,IAAIA,YAAY,CAAC,CAAD,CAAZ,CAAgBI,UAAhB,CAA2B,GAA3B,CAAJ,EAAqC;IACnCD,UAAU,GAAG,IAAAE,YAAA,EAAKL,YAAY,CAAC,CAAD,CAAjB,EAAsBA,YAAY,CAAC,CAAD,CAAlC,CAAb;EACD;;EACDJ,QAAQ,CAACA,QAAQ,CAACG,MAAT,GAAkB,CAAnB,CAAR,GAAiC,GAAEG,WAAI,GAAEC,UAAW,EAApD;EACA,MAAMG,KAAK,GAAGV,QAAQ,CAACS,IAAT,CAAc,cAAd,CAAd;EACA,OAAOC,KAAP;AACD"}
1
+ {"version":3,"names":["getRootDirFromConfigPath","configPath","splitted","split","last","length","lastSplitted","compact","sep","lastModule","startsWith","join","final"],"sources":["calc-root-dir.ts"],"sourcesContent":["import { compact } from 'lodash';\nimport { join, sep } from 'path';\n\nexport function getRootDirFromConfigPath(configPath: string): string {\n const splitted = configPath.split('node_modules');\n const last = splitted[splitted.length - 1];\n const lastSplitted = compact(last.split(sep));\n let lastModule = lastSplitted[0];\n if (lastSplitted[0].startsWith('@')) {\n lastModule = join(lastSplitted[0], lastSplitted[1]);\n }\n splitted[splitted.length - 1] = `${sep}${lastModule}`;\n const final = splitted.join('node_modules');\n return final;\n}\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,SAASA,wBAAwB,CAACC,UAAkB,EAAU;EACnE,MAAMC,QAAQ,GAAGD,UAAU,CAACE,KAAK,CAAC,cAAc,CAAC;EACjD,MAAMC,IAAI,GAAGF,QAAQ,CAACA,QAAQ,CAACG,MAAM,GAAG,CAAC,CAAC;EAC1C,MAAMC,YAAY,GAAG,IAAAC,iBAAO,EAACH,IAAI,CAACD,KAAK,CAACK,WAAG,CAAC,CAAC;EAC7C,IAAIC,UAAU,GAAGH,YAAY,CAAC,CAAC,CAAC;EAChC,IAAIA,YAAY,CAAC,CAAC,CAAC,CAACI,UAAU,CAAC,GAAG,CAAC,EAAE;IACnCD,UAAU,GAAG,IAAAE,YAAI,EAACL,YAAY,CAAC,CAAC,CAAC,EAAEA,YAAY,CAAC,CAAC,CAAC,CAAC;EACrD;EACAJ,QAAQ,CAACA,QAAQ,CAACG,MAAM,GAAG,CAAC,CAAC,GAAI,GAAEG,WAAI,GAAEC,UAAW,EAAC;EACrD,MAAMG,KAAK,GAAGV,QAAQ,CAACS,IAAI,CAAC,cAAc,CAAC;EAC3C,OAAOC,KAAK;AACd"}
package/dist/error.js CHANGED
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.JestError = void 0;
7
-
8
7
  class JestError extends Error {
9
8
  constructor(message, stack, code, type) {
10
9
  super(message);
11
10
  this.code = code;
12
11
  this.type = type;
13
12
  }
14
-
15
13
  get stack() {
16
14
  return this.stack;
17
15
  }
18
-
19
16
  }
20
-
21
17
  exports.JestError = JestError;
22
18
 
23
19
  //# sourceMappingURL=error.js.map
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["JestError","Error","constructor","message","stack","code","type"],"sources":["error.ts"],"sourcesContent":["export class JestError extends Error {\n constructor(message: string, stack?: string | null, public readonly code?: unknown, public readonly type?: string) {\n super(message);\n }\n\n get stack() {\n return this.stack;\n }\n}\n"],"mappings":";;;;;;;AAAO,MAAMA,SAAN,SAAwBC,KAAxB,CAA8B;EACnCC,WAAW,CAACC,OAAD,EAAkBC,KAAlB,EAAyDC,IAAzD,EAAyFC,IAAzF,EAAwG;IACjH,MAAMH,OAAN;IADiH,KAA/CE,IAA+C,GAA/CA,IAA+C;IAAA,KAAfC,IAAe,GAAfA,IAAe;EAElH;;EAEQ,IAALF,KAAK,GAAG;IACV,OAAO,KAAKA,KAAZ;EACD;;AAPkC"}
1
+ {"version":3,"names":["JestError","Error","constructor","message","stack","code","type"],"sources":["error.ts"],"sourcesContent":["export class JestError extends Error {\n constructor(message: string, stack?: string | null, public readonly code?: unknown, public readonly type?: string) {\n super(message);\n }\n\n get stack() {\n return this.stack;\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,SAAS,SAASC,KAAK,CAAC;EACnCC,WAAW,CAACC,OAAe,EAAEC,KAAqB,EAAkBC,IAAc,EAAkBC,IAAa,EAAE;IACjH,KAAK,CAACH,OAAO,CAAC;IAAC,KADmDE,IAAc,GAAdA,IAAc;IAAA,KAAkBC,IAAa,GAAbA,IAAa;EAEjH;EAEA,IAAIF,KAAK,GAAG;IACV,OAAO,IAAI,CAACA,KAAK;EACnB;AACF;AAAC"}
package/dist/index.js CHANGED
@@ -15,24 +15,18 @@ Object.defineProperty(exports, "JestTester", {
15
15
  return _jest().JestTester;
16
16
  }
17
17
  });
18
-
19
18
  function _jest() {
20
19
  const data = require("./jest.tester");
21
-
22
20
  _jest = function () {
23
21
  return data;
24
22
  };
25
-
26
23
  return data;
27
24
  }
28
-
29
25
  function _jest2() {
30
26
  const data = require("./jest.aspect");
31
-
32
27
  _jest2 = function () {
33
28
  return data;
34
29
  };
35
-
36
30
  return data;
37
31
  }
38
32
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { JestTester } from './jest.tester';\nexport type { JestMain } from './jest.main.runtime';\nexport { JestAspect } from './jest.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { JestTester } from './jest.tester';\nexport type { JestMain } from './jest.main.runtime';\nexport { JestAspect } from './jest.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.JestAspect = void 0;
7
-
8
7
  function _harmony() {
9
8
  const data = require("@teambit/harmony");
10
-
11
9
  _harmony = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  const JestAspect = _harmony().Aspect.create({
19
15
  id: 'teambit.defender/jest'
20
16
  });
21
-
22
17
  exports.JestAspect = JestAspect;
23
18
 
24
19
  //# sourceMappingURL=jest.aspect.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["JestAspect","Aspect","create","id"],"sources":["jest.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const JestAspect = Aspect.create({\n id: 'teambit.defender/jest',\n});\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,UAAU,GAAGC,iBAAA,CAAOC,MAAP,CAAc;EACtCC,EAAE,EAAE;AADkC,CAAd,CAAnB"}
1
+ {"version":3,"names":["JestAspect","Aspect","create","id"],"sources":["jest.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const JestAspect = Aspect.create({\n id: 'teambit.defender/jest',\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,UAAU,GAAGC,iBAAM,CAACC,MAAM,CAAC;EACtCC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Logo = void 0;
9
-
10
8
  function _react() {
11
9
  const data = _interopRequireDefault(require("react"));
12
-
13
10
  _react = function () {
14
11
  return data;
15
12
  };
16
-
17
13
  return data;
18
14
  }
19
-
20
15
  const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
21
16
  style: {
22
17
  height: '100%',
@@ -29,7 +24,6 @@ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
29
24
  },
30
25
  src: "https://static.bit.dev/brands/logo-jest.svg"
31
26
  }));
32
-
33
27
  exports.Logo = Logo;
34
28
 
35
29
  //# sourceMappingURL=jest.composition.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["jest.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-jest.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAV;IAAkBC,OAAO,EAAE,MAA3B;IAAmCC,cAAc,EAAE;EAAnD;AAAZ,gBACE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAT,CAAZ;EAA2B,GAAG,EAAC;AAA/B,EADF,CADK"}
1
+ {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["jest.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-jest.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAG,CAAE;EAAC,GAAG,EAAC;AAA6C,EAAG,CAElF;AAAC"}
@@ -1,101 +1,73 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.WORKER_NAME = exports.JestMain = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _cli() {
25
18
  const data = require("@teambit/cli");
26
-
27
19
  _cli = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _logger() {
35
25
  const data = require("@teambit/logger");
36
-
37
26
  _logger = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  function _worker() {
45
32
  const data = require("@teambit/worker");
46
-
47
33
  _worker = function () {
48
34
  return data;
49
35
  };
50
-
51
36
  return data;
52
37
  }
53
-
54
38
  function _jest() {
55
39
  const data = require("./jest.aspect");
56
-
57
40
  _jest = function () {
58
41
  return data;
59
42
  };
60
-
61
43
  return data;
62
44
  }
63
-
64
45
  function _jest2() {
65
46
  const data = require("./jest.tester");
66
-
67
47
  _jest2 = function () {
68
48
  return data;
69
49
  };
70
-
71
50
  return data;
72
51
  }
73
-
74
52
  const WORKER_NAME = 'jest';
75
53
  exports.WORKER_NAME = WORKER_NAME;
76
-
77
54
  class JestMain {
78
55
  constructor(jestWorker, logger) {
79
56
  this.jestWorker = jestWorker;
80
57
  this.logger = logger;
81
58
  }
82
-
83
59
  createTester(jestConfig, jestModulePath = require.resolve('jest'), opts) {
84
60
  return new (_jest2().JestTester)(_jest().JestAspect.id, jestConfig, jestModulePath, this.jestWorker, this.logger, opts);
85
61
  }
86
-
87
62
  static async provider([worker, loggerAspect]) {
88
63
  const logger = loggerAspect.createLogger(_jest().JestAspect.id);
89
64
  const jestWorker = await worker.declareWorker(WORKER_NAME, require.resolve('./jest.worker'));
90
65
  return new JestMain(jestWorker, logger);
91
66
  }
92
-
93
67
  }
94
-
95
68
  exports.JestMain = JestMain;
96
69
  (0, _defineProperty2().default)(JestMain, "runtime", _cli().MainRuntime);
97
70
  (0, _defineProperty2().default)(JestMain, "dependencies", [_worker().WorkerAspect, _logger().LoggerAspect]);
98
-
99
71
  _jest().JestAspect.addRuntime(JestMain);
100
72
 
101
73
  //# sourceMappingURL=jest.main.runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WORKER_NAME","JestMain","constructor","jestWorker","logger","createTester","jestConfig","jestModulePath","require","resolve","opts","JestTester","JestAspect","id","provider","worker","loggerAspect","createLogger","declareWorker","MainRuntime","WorkerAspect","LoggerAspect","addRuntime"],"sources":["jest.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';\nimport { WorkerAspect, WorkerMain, HarmonyWorker } from '@teambit/worker';\nimport { JestAspect } from './jest.aspect';\nimport { JestTester, JestTesterOptions } from './jest.tester';\nimport type { JestWorker } from './jest.worker';\n\nexport const WORKER_NAME = 'jest';\n\nexport class JestMain {\n constructor(private jestWorker: HarmonyWorker<JestWorker>, private logger: Logger) {}\n\n createTester(jestConfig: any, jestModulePath = require.resolve('jest'), opts?: JestTesterOptions) {\n return new JestTester(JestAspect.id, jestConfig, jestModulePath, this.jestWorker, this.logger, opts);\n }\n\n static runtime = MainRuntime;\n static dependencies = [WorkerAspect, LoggerAspect];\n\n static async provider([worker, loggerAspect]: [WorkerMain, LoggerMain]) {\n const logger = loggerAspect.createLogger(JestAspect.id);\n const jestWorker = await worker.declareWorker<JestWorker>(WORKER_NAME, require.resolve('./jest.worker'));\n return new JestMain(jestWorker, logger);\n }\n}\n\nJestAspect.addRuntime(JestMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,WAAW,GAAG,MAApB;;;AAEA,MAAMC,QAAN,CAAe;EACpBC,WAAW,CAASC,UAAT,EAAwDC,MAAxD,EAAwE;IAAA,KAA/DD,UAA+D,GAA/DA,UAA+D;IAAA,KAAhBC,MAAgB,GAAhBA,MAAgB;EAAE;;EAErFC,YAAY,CAACC,UAAD,EAAkBC,cAAc,GAAGC,OAAO,CAACC,OAAR,CAAgB,MAAhB,CAAnC,EAA4DC,IAA5D,EAAsF;IAChG,OAAO,KAAIC,mBAAJ,EAAeC,kBAAA,CAAWC,EAA1B,EAA8BP,UAA9B,EAA0CC,cAA1C,EAA0D,KAAKJ,UAA/D,EAA2E,KAAKC,MAAhF,EAAwFM,IAAxF,CAAP;EACD;;EAKoB,aAARI,QAAQ,CAAC,CAACC,MAAD,EAASC,YAAT,CAAD,EAAmD;IACtE,MAAMZ,MAAM,GAAGY,YAAY,CAACC,YAAb,CAA0BL,kBAAA,CAAWC,EAArC,CAAf;IACA,MAAMV,UAAU,GAAG,MAAMY,MAAM,CAACG,aAAP,CAAiClB,WAAjC,EAA8CQ,OAAO,CAACC,OAAR,CAAgB,eAAhB,CAA9C,CAAzB;IACA,OAAO,IAAIR,QAAJ,CAAaE,UAAb,EAAyBC,MAAzB,CAAP;EACD;;AAdmB;;;gCAATH,Q,aAOMkB,kB;gCAPNlB,Q,kBAQW,CAACmB,sBAAD,EAAeC,sBAAf,C;;AASxBT,kBAAA,CAAWU,UAAX,CAAsBrB,QAAtB"}
1
+ {"version":3,"names":["WORKER_NAME","JestMain","constructor","jestWorker","logger","createTester","jestConfig","jestModulePath","require","resolve","opts","JestTester","JestAspect","id","provider","worker","loggerAspect","createLogger","declareWorker","MainRuntime","WorkerAspect","LoggerAspect","addRuntime"],"sources":["jest.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';\nimport { WorkerAspect, WorkerMain, HarmonyWorker } from '@teambit/worker';\nimport { JestAspect } from './jest.aspect';\nimport { JestTester, JestTesterOptions } from './jest.tester';\nimport type { JestWorker } from './jest.worker';\n\nexport const WORKER_NAME = 'jest';\n\nexport class JestMain {\n constructor(private jestWorker: HarmonyWorker<JestWorker>, private logger: Logger) {}\n\n createTester(jestConfig: any, jestModulePath = require.resolve('jest'), opts?: JestTesterOptions) {\n return new JestTester(JestAspect.id, jestConfig, jestModulePath, this.jestWorker, this.logger, opts);\n }\n\n static runtime = MainRuntime;\n static dependencies = [WorkerAspect, LoggerAspect];\n\n static async provider([worker, loggerAspect]: [WorkerMain, LoggerMain]) {\n const logger = loggerAspect.createLogger(JestAspect.id);\n const jestWorker = await worker.declareWorker<JestWorker>(WORKER_NAME, require.resolve('./jest.worker'));\n return new JestMain(jestWorker, logger);\n }\n}\n\nJestAspect.addRuntime(JestMain);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,WAAW,GAAG,MAAM;AAAC;AAE3B,MAAMC,QAAQ,CAAC;EACpBC,WAAW,CAASC,UAAqC,EAAUC,MAAc,EAAE;IAAA,KAA/DD,UAAqC,GAArCA,UAAqC;IAAA,KAAUC,MAAc,GAAdA,MAAc;EAAG;EAEpFC,YAAY,CAACC,UAAe,EAAEC,cAAc,GAAGC,OAAO,CAACC,OAAO,CAAC,MAAM,CAAC,EAAEC,IAAwB,EAAE;IAChG,OAAO,KAAIC,mBAAU,EAACC,kBAAU,CAACC,EAAE,EAAEP,UAAU,EAAEC,cAAc,EAAE,IAAI,CAACJ,UAAU,EAAE,IAAI,CAACC,MAAM,EAAEM,IAAI,CAAC;EACtG;EAKA,aAAaI,QAAQ,CAAC,CAACC,MAAM,EAAEC,YAAY,CAA2B,EAAE;IACtE,MAAMZ,MAAM,GAAGY,YAAY,CAACC,YAAY,CAACL,kBAAU,CAACC,EAAE,CAAC;IACvD,MAAMV,UAAU,GAAG,MAAMY,MAAM,CAACG,aAAa,CAAalB,WAAW,EAAEQ,OAAO,CAACC,OAAO,CAAC,eAAe,CAAC,CAAC;IACxG,OAAO,IAAIR,QAAQ,CAACE,UAAU,EAAEC,MAAM,CAAC;EACzC;AACF;AAAC;AAAA,gCAfYH,QAAQ,aAOFkB,kBAAW;AAAA,gCAPjBlB,QAAQ,kBAQG,CAACmB,sBAAY,EAAEC,sBAAY,CAAC;AASpDT,kBAAU,CAACU,UAAU,CAACrB,QAAQ,CAAC"}
@@ -1,146 +1,103 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.JestTester = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _path() {
25
18
  const data = require("path");
26
-
27
19
  _path = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _fsExtra() {
35
25
  const data = require("fs-extra");
36
-
37
26
  _fsExtra = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  function _minimatch() {
45
32
  const data = _interopRequireDefault(require("minimatch"));
46
-
47
33
  _minimatch = function () {
48
34
  return data;
49
35
  };
50
-
51
36
  return data;
52
37
  }
53
-
54
38
  function _lodash() {
55
39
  const data = require("lodash");
56
-
57
40
  _lodash = function () {
58
41
  return data;
59
42
  };
60
-
61
43
  return data;
62
44
  }
63
-
64
45
  function _comlink() {
65
46
  const data = require("comlink");
66
-
67
47
  _comlink = function () {
68
48
  return data;
69
49
  };
70
-
71
50
  return data;
72
51
  }
73
-
74
52
  function _tester() {
75
53
  const data = require("@teambit/tester");
76
-
77
54
  _tester = function () {
78
55
  return data;
79
56
  };
80
-
81
57
  return data;
82
58
  }
83
-
84
59
  function _testsResults() {
85
60
  const data = require("@teambit/tests-results");
86
-
87
61
  _testsResults = function () {
88
62
  return data;
89
63
  };
90
-
91
64
  return data;
92
65
  }
93
-
94
66
  function _jestMessageUtil() {
95
67
  const data = require("jest-message-util");
96
-
97
68
  _jestMessageUtil = function () {
98
69
  return data;
99
70
  };
100
-
101
71
  return data;
102
72
  }
103
-
104
73
  function _component() {
105
74
  const data = require("@teambit/component");
106
-
107
75
  _component = function () {
108
76
  return data;
109
77
  };
110
-
111
78
  return data;
112
79
  }
113
-
114
80
  function _sources() {
115
81
  const data = require("@teambit/legacy/dist/consumer/component/sources");
116
-
117
82
  _sources = function () {
118
83
  return data;
119
84
  };
120
-
121
85
  return data;
122
86
  }
123
-
124
87
  function _dependencyResolver() {
125
88
  const data = require("@teambit/dependency-resolver");
126
-
127
89
  _dependencyResolver = function () {
128
90
  return data;
129
91
  };
130
-
131
92
  return data;
132
93
  }
133
-
134
94
  function _error() {
135
95
  const data = require("./error");
136
-
137
96
  _error = function () {
138
97
  return data;
139
98
  };
140
-
141
99
  return data;
142
100
  }
143
-
144
101
  class JestTester {
145
102
  constructor(id, jestConfig, jestModulePath, jestWorker, logger, opts = {}) {
146
103
  this.id = id;
@@ -156,15 +113,12 @@ class JestTester {
156
113
  // eslint-disable-next-line global-require,import/no-dynamic-require
157
114
  this.jestModule = require(jestModulePath);
158
115
  }
159
-
160
116
  displayConfig() {
161
117
  return (0, _fsExtra().readFileSync)(this.jestConfig, 'utf8');
162
118
  }
163
-
164
119
  version() {
165
120
  return this.jestModule.getVersion();
166
121
  }
167
-
168
122
  attachTestsToComponent(testerContext, testResult) {
169
123
  return _component().ComponentMap.as(testerContext.components, component => {
170
124
  const componentPatternValue = testerContext.patterns.get(component);
@@ -176,7 +130,6 @@ class JestTester {
176
130
  });
177
131
  });
178
132
  }
179
-
180
133
  buildTestsObj(aggregatedResult, components, testerContext, config) {
181
134
  const testsSuiteResult = components.toArray().map(([component, testsFiles]) => {
182
135
  if (!testsFiles) return undefined;
@@ -195,22 +148,17 @@ class JestTester {
195
148
  return new (_testsResults().TestResult)(testResult.ancestorTitles, testResult.title, testResult.status, testResult.duration, isFailure ? undefined : error, isFailure ? error : undefined);
196
149
  });
197
150
  const filePath = (file === null || file === void 0 ? void 0 : file.basename) || test.testFilePath;
198
-
199
151
  const getError = () => {
200
152
  var _test$testExecError, _test$testExecError2;
201
-
202
153
  if (!test.testExecError) return undefined;
203
-
204
154
  if (testerContext.watch) {
205
155
  // for some reason, during watch ('bit start'), if a file has an error, the `test.testExecError` is `{}`
206
156
  // (an empty object). the failureMessage contains the stringified error.
207
157
  // @todo: consider to always use the failureMessage, regardless the context.watch.
208
158
  return new (_error().JestError)(test.failureMessage);
209
159
  }
210
-
211
160
  return new (_error().JestError)((_test$testExecError = test.testExecError) === null || _test$testExecError === void 0 ? void 0 : _test$testExecError.message, (_test$testExecError2 = test.testExecError) === null || _test$testExecError2 === void 0 ? void 0 : _test$testExecError2.stack);
212
161
  };
213
-
214
162
  const error = getError();
215
163
  return new (_testsResults().TestsFiles)(filePath, testResults, test.numPassingTests, test.numFailingTests, test.numPendingTests, test.perfStats.runtime, test.perfStats.slow, error);
216
164
  });
@@ -222,7 +170,6 @@ class JestTester {
222
170
  });
223
171
  return (0, _lodash().compact)(testsSuiteResult);
224
172
  }
225
-
226
173
  getErrors(testResult) {
227
174
  return testResult.reduce((errors, test) => {
228
175
  if (test.testExecError) {
@@ -236,17 +183,15 @@ class JestTester {
236
183
  } else if (test.failureMessage) {
237
184
  errors.push(new (_error().JestError)(test.failureMessage));
238
185
  }
239
-
240
186
  return errors;
241
187
  }, []);
242
188
  }
243
-
244
189
  async onTestRunComplete(callback) {
245
190
  this._callback = callback;
246
191
  }
247
-
248
192
  async test(context) {
249
193
  // const envRootDir = context.envRuntime.envAspectDefinition.aspectPath;
194
+
250
195
  const config = {
251
196
  // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins
252
197
  // from the env context
@@ -263,27 +208,26 @@ class JestTester {
263
208
  // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)
264
209
  // TODO: didn't help)
265
210
  roots: [context.rootPath]
266
- }; // eslint-disable-next-line no-console
211
+ };
267
212
 
213
+ // eslint-disable-next-line no-console
268
214
  console.warn = message => {
269
215
  this.logger.warn(message);
270
216
  };
271
-
272
217
  if (context.debug) {
273
218
  config.debug = true;
274
219
  config.runInBand = true;
275
220
  }
276
-
277
221
  if (context.coverage) config.coverage = true;
278
222
  config.runInBand = true;
279
-
280
223
  if (context.watch) {
281
224
  config.watchAll = true;
282
225
  config.noCache = true;
283
- } // eslint-disable-next-line global-require,import/no-dynamic-require
284
-
226
+ }
227
+ // eslint-disable-next-line global-require,import/no-dynamic-require
228
+ const jestConfig = require(this.jestConfig);
285
229
 
286
- const jestConfig = require(this.jestConfig); // TODO: rollback this for now, as it makes issues.
230
+ // TODO: rollback this for now, as it makes issues.
287
231
  // TODO: it's mostly relevant for when the root components feature is enabled.
288
232
  // TODO: we might want to enable it only on that case (along with setting the env root dir as the root dir, above)
289
233
  // const moduleNameMapper = await this.calculateModuleNameMapper(
@@ -293,7 +237,6 @@ class JestTester {
293
237
  // );
294
238
  // jestConfig.moduleNameMapper = Object.assign({}, jestConfig.moduleNameMapper || {}, moduleNameMapper);
295
239
 
296
-
297
240
  const jestConfigWithSpecs = Object.assign(jestConfig, {
298
241
  testMatch: this.patternsToArray(context)
299
242
  });
@@ -304,12 +247,10 @@ class JestTester {
304
247
  const componentTestResults = this.buildTestsObj(testsOutPut.results, componentsWithTests, context, jestConfigWithSpecs);
305
248
  return new (_tester().Tests)(componentTestResults);
306
249
  }
307
-
308
250
  async watch(context) {
309
251
  // eslint-disable-next-line
310
252
  return new Promise(async resolve => {
311
253
  var _context$envRuntime$e;
312
-
313
254
  const workerApi = this.jestWorker.initiate(context.ui ? {
314
255
  stdout: true,
315
256
  stderr: true,
@@ -318,20 +259,17 @@ class JestTester {
318
259
  stdout: false,
319
260
  stderr: false,
320
261
  stdin: false
321
- }); // eslint-disable-next-line
262
+ });
322
263
 
264
+ // eslint-disable-next-line
323
265
  const jestConfig = require(this.jestConfig);
324
-
325
266
  const envRootDir = (_context$envRuntime$e = context.envRuntime.envAspectDefinition) === null || _context$envRuntime$e === void 0 ? void 0 : _context$envRuntime$e.aspectPath;
326
-
327
267
  if (!envRootDir) {
328
268
  this.logger.warn(`jest tester, envRootDir is not defined, for env ${context.envRuntime.id}`);
329
269
  }
330
-
331
270
  const jestConfigWithSpecs = Object.assign(jestConfig, {
332
271
  testMatch: this.patternsToArray(context)
333
272
  });
334
-
335
273
  try {
336
274
  const cbFn = (0, _comlink().proxy)(results => {
337
275
  if (!this._callback) return;
@@ -344,12 +282,11 @@ class JestTester {
344
282
  errors: globalErrors,
345
283
  components: componentTestResults
346
284
  };
347
-
348
285
  this._callback(watchTestResults);
349
-
350
286
  resolve(watchTestResults);
351
- }); // eslint-disable-next-line @typescript-eslint/no-floating-promises
287
+ });
352
288
 
289
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
353
290
  await workerApi.onTestComplete(cbFn);
354
291
  await workerApi.watch(this.jestConfig, this.patternsToArray(context), context.rootPath, this.jestModulePath, envRootDir);
355
292
  } catch (err) {
@@ -357,16 +294,15 @@ class JestTester {
357
294
  }
358
295
  });
359
296
  }
360
-
361
297
  async calculateModuleNameMapper(env, rootPath, additionalHostDependencies) {
362
298
  const peerDepsConfig = await env.getDependencies();
363
299
  const peersAutoDetectPolicy = new (_dependencyResolver().PeersAutoDetectPolicy)(peerDepsConfig.peers || []);
364
300
  const peers = Object.keys(peerDepsConfig.peerDependencies || {}).concat(peersAutoDetectPolicy === null || peersAutoDetectPolicy === void 0 ? void 0 : peersAutoDetectPolicy.names);
365
301
  const depsToMap = peers.concat(additionalHostDependencies || []);
302
+
366
303
  /**
367
304
  * Try to resolve the dependency from the rootDir (the env dir) or from the root path (workspace/capsule root)
368
305
  */
369
-
370
306
  const mappedValues = ['<rootDir>/node_modules/$1', `${rootPath}/node_modules/$1`];
371
307
  const moduleNameMapper = depsToMap.reduce((acc, peerName) => {
372
308
  const keyName = `^(${peerName})$`;
@@ -377,36 +313,29 @@ class JestTester {
377
313
  }, {});
378
314
  return moduleNameMapper;
379
315
  }
380
-
381
316
  patternsToArray(context) {
382
317
  return (0, _lodash().flatten)(context.patterns.toArray().map(([component, patternEntry]) => {
383
318
  return this.resolveComponentPattern(component, patternEntry, context);
384
319
  }));
385
320
  }
386
-
387
321
  resolveComponentPattern(component, patternEntry, context) {
388
322
  if (this.opts.resolveSpecPaths) {
389
323
  return this.opts.resolveSpecPaths(component, context);
390
324
  }
391
-
392
- const customPatterns = this.opts.patterns; // If pattern were provided to the specific instance of the tester, use them
393
-
325
+ const customPatterns = this.opts.patterns;
326
+ // If pattern were provided to the specific instance of the tester, use them
394
327
  if (customPatterns && !(0, _lodash().isEmpty)(customPatterns)) {
395
328
  customPatterns.map(customPattern => {
396
329
  const rootDirs = this.opts.roots || [patternEntry.componentDir];
397
330
  return this.resolvePattern(customPattern, rootDirs);
398
331
  });
399
332
  }
400
-
401
333
  return patternEntry.paths.map(p => p.path);
402
334
  }
403
-
404
335
  resolvePattern(pattern, rootDirs) {
405
336
  return rootDirs.map(dir => (0, _path().resolve)(dir, pattern));
406
337
  }
407
-
408
338
  }
409
-
410
339
  exports.JestTester = JestTester;
411
340
 
412
341
  //# sourceMappingURL=jest.tester.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["JestTester","constructor","id","jestConfig","jestModulePath","jestWorker","logger","opts","jestModule","require","displayConfig","readFileSync","version","getVersion","attachTestsToComponent","testerContext","testResult","ComponentMap","as","components","component","componentPatternValue","patterns","get","undefined","currComponent","patternEntry","resolvedPatterns","resolveComponentPattern","filter","test","resolvedPattern","minimatch","testFilePath","length","buildTestsObj","aggregatedResult","config","testsSuiteResult","toArray","map","testsFiles","errors","getErrors","tests","file","AbstractVinyl","path","contents","testResults","error","formatResultsErrors","noStackTrace","isFailure","status","TestResult","ancestorTitles","title","duration","filePath","basename","getError","testExecError","watch","JestError","failureMessage","message","stack","TestsFiles","numPassingTests","numFailingTests","numPendingTests","perfStats","runtime","slow","componentId","results","TestsResult","success","startTime","compact","reduce","code","type","push","onTestRunComplete","callback","_callback","context","rootDir","rootPath","roots","console","warn","debug","runInBand","coverage","watchAll","noCache","jestConfigWithSpecs","Object","assign","testMatch","patternsToArray","withEnv","testsOutPut","runCLI","componentsWithTests","componentTestResults","Tests","Promise","resolve","workerApi","initiate","ui","stdout","stderr","stdin","envRootDir","envRuntime","envAspectDefinition","aspectPath","cbFn","proxy","globalErrors","watchTestResults","loading","onTestComplete","err","calculateModuleNameMapper","env","additionalHostDependencies","peerDepsConfig","getDependencies","peersAutoDetectPolicy","PeersAutoDetectPolicy","peers","keys","peerDependencies","concat","names","depsToMap","mappedValues","moduleNameMapper","acc","peerName","keyName","internalPathKeyName","flatten","resolveSpecPaths","customPatterns","isEmpty","customPattern","rootDirs","componentDir","resolvePattern","paths","p","pattern","dir"],"sources":["jest.tester.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { readFileSync } from 'fs-extra';\nimport minimatch from 'minimatch';\nimport { compact, flatten, isEmpty } from 'lodash';\nimport { proxy } from 'comlink';\nimport { Logger } from '@teambit/logger';\nimport { HarmonyWorker } from '@teambit/worker';\nimport { Tester, CallbackFn, TesterContext, Tests, ComponentsResults, ComponentPatternsEntry } from '@teambit/tester';\nimport { TestsFiles, TestResult, TestsResult } from '@teambit/tests-results';\nimport { TestResult as JestTestResult, AggregatedResult } from '@jest/test-result';\nimport { formatResultsErrors } from 'jest-message-util';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Environment } from '@teambit/envs';\nimport { EnvPolicyConfigObject, PeersAutoDetectPolicy } from '@teambit/dependency-resolver';\nimport type jest from 'jest';\nimport { JestError } from './error';\nimport type { JestWorker } from './jest.worker';\n\nexport type JestTesterOptions = {\n /**\n * array of patterns to test. (override the patterns provided by the context)\n */\n patterns?: string[];\n\n /**\n * add more root paths to look for tests.\n */\n roots?: string[];\n\n /**\n * A function that knows to resolve the paths of the spec files.\n * This usually used when you want only subset of your spec files to be used\n * (usually when you use multi tester with different specs files for each tester instance).\n */\n resolveSpecPaths?: (component: Component, context: TesterContext) => string[];\n};\n\nexport class JestTester implements Tester {\n private readonly jestModule: typeof jest;\n\n constructor(\n readonly id: string,\n readonly jestConfig: any,\n private jestModulePath: string,\n private jestWorker: HarmonyWorker<JestWorker>,\n private logger: Logger,\n private opts: JestTesterOptions = {}\n ) {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n this.jestModule = require(jestModulePath);\n }\n\n configPath = this.jestConfig;\n\n displayName = 'Jest';\n\n _callback: CallbackFn | undefined;\n\n displayConfig() {\n return readFileSync(this.jestConfig, 'utf8');\n }\n\n version() {\n return this.jestModule.getVersion();\n }\n\n private attachTestsToComponent(testerContext: TesterContext, testResult: JestTestResult[]) {\n return ComponentMap.as(testerContext.components, (component) => {\n const componentPatternValue = testerContext.patterns.get(component);\n if (!componentPatternValue) return undefined;\n const [currComponent, patternEntry] = componentPatternValue;\n const resolvedPatterns = this.resolveComponentPattern(currComponent, patternEntry, testerContext);\n return testResult.filter((test) => {\n return resolvedPatterns.filter((resolvedPattern) => minimatch(test.testFilePath, resolvedPattern)).length > 0;\n });\n });\n }\n\n private buildTestsObj(\n aggregatedResult: AggregatedResult,\n components: ComponentMap<JestTestResult[] | undefined>,\n testerContext: TesterContext,\n config?: any\n ): ComponentsResults[] {\n const testsSuiteResult = components.toArray().map(([component, testsFiles]) => {\n if (!testsFiles) return undefined;\n if (testsFiles?.length === 0) return undefined;\n const errors = this.getErrors(testsFiles);\n const tests = testsFiles.map((test) => {\n const file = new AbstractVinyl({ path: test.testFilePath, contents: readFileSync(test.testFilePath) });\n const testResults = test.testResults.map((testResult) => {\n const error = formatResultsErrors([testResult], config, { noStackTrace: true }) || undefined;\n const isFailure = testResult.status === 'failed';\n return new TestResult(\n testResult.ancestorTitles,\n testResult.title,\n testResult.status,\n testResult.duration,\n isFailure ? undefined : error,\n isFailure ? error : undefined\n );\n });\n const filePath = file?.basename || test.testFilePath;\n const getError = () => {\n if (!test.testExecError) return undefined;\n if (testerContext.watch) {\n // for some reason, during watch ('bit start'), if a file has an error, the `test.testExecError` is `{}`\n // (an empty object). the failureMessage contains the stringified error.\n // @todo: consider to always use the failureMessage, regardless the context.watch.\n return new JestError(test.failureMessage as string);\n }\n return new JestError(test.testExecError?.message, test.testExecError?.stack);\n };\n const error = getError();\n return new TestsFiles(\n filePath,\n testResults,\n test.numPassingTests,\n test.numFailingTests,\n test.numPendingTests,\n test.perfStats.runtime,\n test.perfStats.slow,\n error\n );\n });\n return {\n componentId: component.id,\n results: new TestsResult(tests, aggregatedResult.success, aggregatedResult.startTime),\n errors,\n };\n });\n\n return compact(testsSuiteResult);\n }\n\n private getErrors(testResult: JestTestResult[]): JestError[] {\n return testResult.reduce((errors: JestError[], test) => {\n if (test.testExecError) {\n const { message, stack, code, type } = test.testExecError;\n errors.push(new JestError(message, stack, code, type));\n } else if (test.failureMessage) {\n errors.push(new JestError(test.failureMessage));\n }\n return errors;\n }, []);\n }\n\n async onTestRunComplete(callback: CallbackFn) {\n this._callback = callback;\n }\n\n async test(context: TesterContext): Promise<Tests> {\n // const envRootDir = context.envRuntime.envAspectDefinition.aspectPath;\n\n const config: any = {\n // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins\n // from the env context\n // rootDir: envRootDir,\n // TODO: set it to envRootDir and make sure we can make the --coverage to work\n // with the current value as context.rootPath it will probably won't work correctly when using rootComponents:true (maybe even won't work at all)\n // TODO: when changing to envRootDir we have some issues with the react-native tests. so once changed again, it needs to be validated.\n rootDir: context.rootPath,\n // Setting the roots (where to search for spec files) to the root path (either workspace or capsule root)\n // TODO: consider change this to be an array of the components running dir.\n // TODO: aka: in the workspace it will be something like <ws>/node_modules/<comp-package-name>/node_modules/<comp-package-name>\n // TODO: see dependencyResolver.getRuntimeModulePath (this will make sure the peer deps resolved correctly)\n // TODO: (@GiladShoham - when trying to set it to this paths, jest ignores it probably because the paths contains \"node_modules\"\n // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)\n // TODO: didn't help)\n roots: [context.rootPath],\n };\n\n // eslint-disable-next-line no-console\n console.warn = (message: string) => {\n this.logger.warn(message);\n };\n\n if (context.debug) {\n config.debug = true;\n config.runInBand = true;\n }\n if (context.coverage) config.coverage = true;\n config.runInBand = true;\n\n if (context.watch) {\n config.watchAll = true;\n config.noCache = true;\n }\n // eslint-disable-next-line global-require,import/no-dynamic-require\n const jestConfig = require(this.jestConfig);\n\n // TODO: rollback this for now, as it makes issues.\n // TODO: it's mostly relevant for when the root components feature is enabled.\n // TODO: we might want to enable it only on that case (along with setting the env root dir as the root dir, above)\n // const moduleNameMapper = await this.calculateModuleNameMapper(\n // context.env,\n // context.rootPath,\n // context.additionalHostDependencies\n // );\n // jestConfig.moduleNameMapper = Object.assign({}, jestConfig.moduleNameMapper || {}, moduleNameMapper);\n\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context),\n });\n\n const withEnv = Object.assign(jestConfigWithSpecs, config);\n\n const testsOutPut = await this.jestModule.runCLI(withEnv, [this.jestConfig]);\n const testResults = testsOutPut.results.testResults;\n const componentsWithTests = this.attachTestsToComponent(context, testResults);\n const componentTestResults = this.buildTestsObj(\n testsOutPut.results,\n componentsWithTests,\n context,\n jestConfigWithSpecs\n );\n return new Tests(componentTestResults);\n }\n\n async watch(context: TesterContext): Promise<Tests> {\n // eslint-disable-next-line\n return new Promise(async (resolve) => {\n const workerApi = this.jestWorker.initiate(\n context.ui ? { stdout: true, stderr: true, stdin: true } : { stdout: false, stderr: false, stdin: false }\n );\n\n // eslint-disable-next-line\n const jestConfig = require(this.jestConfig);\n\n const envRootDir = context.envRuntime.envAspectDefinition?.aspectPath;\n if (!envRootDir) {\n this.logger.warn(`jest tester, envRootDir is not defined, for env ${context.envRuntime.id}`);\n }\n\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context),\n });\n\n try {\n const cbFn = proxy((results) => {\n if (!this._callback) return;\n const testResults = results.testResults;\n const componentsWithTests = this.attachTestsToComponent(context, testResults);\n const componentTestResults = this.buildTestsObj(results, componentsWithTests, context, jestConfigWithSpecs);\n const globalErrors = this.getErrors(testResults);\n const watchTestResults = {\n loading: false,\n errors: globalErrors,\n components: componentTestResults,\n };\n this._callback(watchTestResults);\n resolve(watchTestResults);\n });\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n await workerApi.onTestComplete(cbFn);\n\n await workerApi.watch(\n this.jestConfig,\n this.patternsToArray(context),\n context.rootPath,\n this.jestModulePath,\n envRootDir\n );\n } catch (err: any) {\n this.logger.error('jest.tester.watch() caught an error', err);\n }\n });\n }\n\n private async calculateModuleNameMapper(\n env: Environment,\n rootPath: string,\n additionalHostDependencies?: string[]\n ): Promise<Record<string, Array<string>>> {\n const peerDepsConfig: EnvPolicyConfigObject = await env.getDependencies();\n const peersAutoDetectPolicy = new PeersAutoDetectPolicy(peerDepsConfig.peers || []);\n const peers = Object.keys(peerDepsConfig.peerDependencies || {}).concat(peersAutoDetectPolicy?.names);\n const depsToMap = peers.concat(additionalHostDependencies || []);\n\n /**\n * Try to resolve the dependency from the rootDir (the env dir) or from the root path (workspace/capsule root)\n */\n const mappedValues = ['<rootDir>/node_modules/$1', `${rootPath}/node_modules/$1`];\n\n const moduleNameMapper = depsToMap.reduce((acc, peerName) => {\n const keyName = `^(${peerName})$`;\n acc[keyName] = mappedValues;\n const internalPathKeyName = `^(${peerName}/.*)$`;\n acc[internalPathKeyName] = mappedValues;\n return acc;\n }, {});\n\n return moduleNameMapper;\n }\n\n private patternsToArray(context: TesterContext): string[] {\n return flatten(\n context.patterns.toArray().map(([component, patternEntry]) => {\n return this.resolveComponentPattern(component, patternEntry, context);\n })\n );\n }\n\n private resolveComponentPattern(\n component: Component,\n patternEntry: ComponentPatternsEntry,\n context: TesterContext\n ): string[] {\n if (this.opts.resolveSpecPaths) {\n return this.opts.resolveSpecPaths(component, context);\n }\n const customPatterns = this.opts.patterns;\n // If pattern were provided to the specific instance of the tester, use them\n if (customPatterns && !isEmpty(customPatterns)) {\n customPatterns.map((customPattern) => {\n const rootDirs = this.opts.roots || [patternEntry.componentDir];\n return this.resolvePattern(customPattern, rootDirs);\n });\n }\n return patternEntry.paths.map((p) => p.path);\n }\n\n private resolvePattern(pattern: string, rootDirs: string[]) {\n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d,CAApC;QACA,OAAO,KAAKC,cAAL,CAAoBH,aAApB,EAAmCC,QAAnC,CAAP;MACD,CAHD;IAID;;IACD,OAAO/H,YAAY,CAACkI,KAAb,CAAmBpH,GAAnB,CAAwBqH,CAAD,IAAOA,CAAC,CAAC9G,IAAhC,CAAP;EACD;;EAEO4G,cAAc,CAACG,OAAD,EAAkBL,QAAlB,EAAsC;IAC1D,OAAOA,QAAQ,CAACjH,GAAT,CAAcuH,GAAD,IAAS,IAAAhD,eAAA,EAAQgD,GAAR,EAAaD,OAAb,CAAtB,CAAP;EACD;;AAhSuC"}
1
+ {"version":3,"names":["JestTester","constructor","id","jestConfig","jestModulePath","jestWorker","logger","opts","jestModule","require","displayConfig","readFileSync","version","getVersion","attachTestsToComponent","testerContext","testResult","ComponentMap","as","components","component","componentPatternValue","patterns","get","undefined","currComponent","patternEntry","resolvedPatterns","resolveComponentPattern","filter","test","resolvedPattern","minimatch","testFilePath","length","buildTestsObj","aggregatedResult","config","testsSuiteResult","toArray","map","testsFiles","errors","getErrors","tests","file","AbstractVinyl","path","contents","testResults","error","formatResultsErrors","noStackTrace","isFailure","status","TestResult","ancestorTitles","title","duration","filePath","basename","getError","testExecError","watch","JestError","failureMessage","message","stack","TestsFiles","numPassingTests","numFailingTests","numPendingTests","perfStats","runtime","slow","componentId","results","TestsResult","success","startTime","compact","reduce","code","type","push","onTestRunComplete","callback","_callback","context","rootDir","rootPath","roots","console","warn","debug","runInBand","coverage","watchAll","noCache","jestConfigWithSpecs","Object","assign","testMatch","patternsToArray","withEnv","testsOutPut","runCLI","componentsWithTests","componentTestResults","Tests","Promise","resolve","workerApi","initiate","ui","stdout","stderr","stdin","envRootDir","envRuntime","envAspectDefinition","aspectPath","cbFn","proxy","globalErrors","watchTestResults","loading","onTestComplete","err","calculateModuleNameMapper","env","additionalHostDependencies","peerDepsConfig","getDependencies","peersAutoDetectPolicy","PeersAutoDetectPolicy","peers","keys","peerDependencies","concat","names","depsToMap","mappedValues","moduleNameMapper","acc","peerName","keyName","internalPathKeyName","flatten","resolveSpecPaths","customPatterns","isEmpty","customPattern","rootDirs","componentDir","resolvePattern","paths","p","pattern","dir"],"sources":["jest.tester.ts"],"sourcesContent":["import { resolve } from 'path';\nimport { readFileSync } from 'fs-extra';\nimport minimatch from 'minimatch';\nimport { compact, flatten, isEmpty } from 'lodash';\nimport { proxy } from 'comlink';\nimport { Logger } from '@teambit/logger';\nimport { HarmonyWorker } from '@teambit/worker';\nimport { Tester, CallbackFn, TesterContext, Tests, ComponentsResults, ComponentPatternsEntry } from '@teambit/tester';\nimport { TestsFiles, TestResult, TestsResult } from '@teambit/tests-results';\nimport { TestResult as JestTestResult, AggregatedResult } from '@jest/test-result';\nimport { formatResultsErrors } from 'jest-message-util';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Environment } from '@teambit/envs';\nimport { EnvPolicyConfigObject, PeersAutoDetectPolicy } from '@teambit/dependency-resolver';\nimport type jest from 'jest';\nimport { JestError } from './error';\nimport type { JestWorker } from './jest.worker';\n\nexport type JestTesterOptions = {\n /**\n * array of patterns to test. (override the patterns provided by the context)\n */\n patterns?: string[];\n\n /**\n * add more root paths to look for tests.\n */\n roots?: string[];\n\n /**\n * A function that knows to resolve the paths of the spec files.\n * This usually used when you want only subset of your spec files to be used\n * (usually when you use multi tester with different specs files for each tester instance).\n */\n resolveSpecPaths?: (component: Component, context: TesterContext) => string[];\n};\n\nexport class JestTester implements Tester {\n private readonly jestModule: typeof jest;\n\n constructor(\n readonly id: string,\n readonly jestConfig: any,\n private jestModulePath: string,\n private jestWorker: HarmonyWorker<JestWorker>,\n private logger: Logger,\n private opts: JestTesterOptions = {}\n ) {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n this.jestModule = require(jestModulePath);\n }\n\n configPath = this.jestConfig;\n\n displayName = 'Jest';\n\n _callback: CallbackFn | undefined;\n\n displayConfig() {\n return readFileSync(this.jestConfig, 'utf8');\n }\n\n version() {\n return this.jestModule.getVersion();\n }\n\n private attachTestsToComponent(testerContext: TesterContext, testResult: JestTestResult[]) {\n return ComponentMap.as(testerContext.components, (component) => {\n const componentPatternValue = testerContext.patterns.get(component);\n if (!componentPatternValue) return undefined;\n const [currComponent, patternEntry] = componentPatternValue;\n const resolvedPatterns = this.resolveComponentPattern(currComponent, patternEntry, testerContext);\n return testResult.filter((test) => {\n return resolvedPatterns.filter((resolvedPattern) => minimatch(test.testFilePath, resolvedPattern)).length > 0;\n });\n });\n }\n\n private buildTestsObj(\n aggregatedResult: AggregatedResult,\n components: ComponentMap<JestTestResult[] | undefined>,\n testerContext: TesterContext,\n config?: any\n ): ComponentsResults[] {\n const testsSuiteResult = components.toArray().map(([component, testsFiles]) => {\n if (!testsFiles) return undefined;\n if (testsFiles?.length === 0) return undefined;\n const errors = this.getErrors(testsFiles);\n const tests = testsFiles.map((test) => {\n const file = new AbstractVinyl({ path: test.testFilePath, contents: readFileSync(test.testFilePath) });\n const testResults = test.testResults.map((testResult) => {\n const error = formatResultsErrors([testResult], config, { noStackTrace: true }) || undefined;\n const isFailure = testResult.status === 'failed';\n return new TestResult(\n testResult.ancestorTitles,\n testResult.title,\n testResult.status,\n testResult.duration,\n isFailure ? undefined : error,\n isFailure ? error : undefined\n );\n });\n const filePath = file?.basename || test.testFilePath;\n const getError = () => {\n if (!test.testExecError) return undefined;\n if (testerContext.watch) {\n // for some reason, during watch ('bit start'), if a file has an error, the `test.testExecError` is `{}`\n // (an empty object). the failureMessage contains the stringified error.\n // @todo: consider to always use the failureMessage, regardless the context.watch.\n return new JestError(test.failureMessage as string);\n }\n return new JestError(test.testExecError?.message, test.testExecError?.stack);\n };\n const error = getError();\n return new TestsFiles(\n filePath,\n testResults,\n test.numPassingTests,\n test.numFailingTests,\n test.numPendingTests,\n test.perfStats.runtime,\n test.perfStats.slow,\n error\n );\n });\n return {\n componentId: component.id,\n results: new TestsResult(tests, aggregatedResult.success, aggregatedResult.startTime),\n errors,\n };\n });\n\n return compact(testsSuiteResult);\n }\n\n private getErrors(testResult: JestTestResult[]): JestError[] {\n return testResult.reduce((errors: JestError[], test) => {\n if (test.testExecError) {\n const { message, stack, code, type } = test.testExecError;\n errors.push(new JestError(message, stack, code, type));\n } else if (test.failureMessage) {\n errors.push(new JestError(test.failureMessage));\n }\n return errors;\n }, []);\n }\n\n async onTestRunComplete(callback: CallbackFn) {\n this._callback = callback;\n }\n\n async test(context: TesterContext): Promise<Tests> {\n // const envRootDir = context.envRuntime.envAspectDefinition.aspectPath;\n\n const config: any = {\n // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins\n // from the env context\n // rootDir: envRootDir,\n // TODO: set it to envRootDir and make sure we can make the --coverage to work\n // with the current value as context.rootPath it will probably won't work correctly when using rootComponents:true (maybe even won't work at all)\n // TODO: when changing to envRootDir we have some issues with the react-native tests. so once changed again, it needs to be validated.\n rootDir: context.rootPath,\n // Setting the roots (where to search for spec files) to the root path (either workspace or capsule root)\n // TODO: consider change this to be an array of the components running dir.\n // TODO: aka: in the workspace it will be something like <ws>/node_modules/<comp-package-name>/node_modules/<comp-package-name>\n // TODO: see dependencyResolver.getRuntimeModulePath (this will make sure the peer deps resolved correctly)\n // TODO: (@GiladShoham - when trying to set it to this paths, jest ignores it probably because the paths contains \"node_modules\"\n // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)\n // TODO: didn't help)\n roots: [context.rootPath],\n };\n\n // eslint-disable-next-line no-console\n console.warn = (message: string) => {\n this.logger.warn(message);\n };\n\n if (context.debug) {\n config.debug = true;\n config.runInBand = true;\n }\n if (context.coverage) config.coverage = true;\n config.runInBand = true;\n\n if (context.watch) {\n config.watchAll = true;\n config.noCache = true;\n }\n // eslint-disable-next-line global-require,import/no-dynamic-require\n const jestConfig = require(this.jestConfig);\n\n // TODO: rollback this for now, as it makes issues.\n // TODO: it's mostly relevant for when the root components feature is enabled.\n // TODO: we might want to enable it only on that case (along with setting the env root dir as the root dir, above)\n // const moduleNameMapper = await this.calculateModuleNameMapper(\n // context.env,\n // context.rootPath,\n // context.additionalHostDependencies\n // );\n // jestConfig.moduleNameMapper = Object.assign({}, jestConfig.moduleNameMapper || {}, moduleNameMapper);\n\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context),\n });\n\n const withEnv = Object.assign(jestConfigWithSpecs, config);\n\n const testsOutPut = await this.jestModule.runCLI(withEnv, [this.jestConfig]);\n const testResults = testsOutPut.results.testResults;\n const componentsWithTests = this.attachTestsToComponent(context, testResults);\n const componentTestResults = this.buildTestsObj(\n testsOutPut.results,\n componentsWithTests,\n context,\n jestConfigWithSpecs\n );\n return new Tests(componentTestResults);\n }\n\n async watch(context: TesterContext): Promise<Tests> {\n // eslint-disable-next-line\n return new Promise(async (resolve) => {\n const workerApi = this.jestWorker.initiate(\n context.ui ? { stdout: true, stderr: true, stdin: true } : { stdout: false, stderr: false, stdin: false }\n );\n\n // eslint-disable-next-line\n const jestConfig = require(this.jestConfig);\n\n const envRootDir = context.envRuntime.envAspectDefinition?.aspectPath;\n if (!envRootDir) {\n this.logger.warn(`jest tester, envRootDir is not defined, for env ${context.envRuntime.id}`);\n }\n\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context),\n });\n\n try {\n const cbFn = proxy((results) => {\n if (!this._callback) return;\n const testResults = results.testResults;\n const componentsWithTests = this.attachTestsToComponent(context, testResults);\n const componentTestResults = this.buildTestsObj(results, componentsWithTests, context, jestConfigWithSpecs);\n const globalErrors = this.getErrors(testResults);\n const watchTestResults = {\n loading: false,\n errors: globalErrors,\n components: componentTestResults,\n };\n this._callback(watchTestResults);\n resolve(watchTestResults);\n });\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n await workerApi.onTestComplete(cbFn);\n\n await workerApi.watch(\n this.jestConfig,\n this.patternsToArray(context),\n context.rootPath,\n this.jestModulePath,\n envRootDir\n );\n } catch (err: any) {\n this.logger.error('jest.tester.watch() caught an error', err);\n }\n });\n }\n\n private async calculateModuleNameMapper(\n env: Environment,\n rootPath: string,\n additionalHostDependencies?: string[]\n ): Promise<Record<string, Array<string>>> {\n const peerDepsConfig: EnvPolicyConfigObject = await env.getDependencies();\n const peersAutoDetectPolicy = new PeersAutoDetectPolicy(peerDepsConfig.peers || []);\n const peers = Object.keys(peerDepsConfig.peerDependencies || {}).concat(peersAutoDetectPolicy?.names);\n const depsToMap = peers.concat(additionalHostDependencies || []);\n\n /**\n * Try to resolve the dependency from the rootDir (the env dir) or from the root path (workspace/capsule root)\n */\n const mappedValues = ['<rootDir>/node_modules/$1', `${rootPath}/node_modules/$1`];\n\n const moduleNameMapper = depsToMap.reduce((acc, peerName) => {\n const keyName = `^(${peerName})$`;\n acc[keyName] = mappedValues;\n const internalPathKeyName = `^(${peerName}/.*)$`;\n acc[internalPathKeyName] = mappedValues;\n return acc;\n }, {});\n\n return moduleNameMapper;\n }\n\n private patternsToArray(context: TesterContext): string[] {\n return flatten(\n context.patterns.toArray().map(([component, patternEntry]) => {\n return this.resolveComponentPattern(component, patternEntry, context);\n })\n );\n }\n\n private resolveComponentPattern(\n component: Component,\n patternEntry: ComponentPatternsEntry,\n context: TesterContext\n ): string[] {\n if (this.opts.resolveSpecPaths) {\n return this.opts.resolveSpecPaths(component, context);\n }\n const customPatterns = this.opts.patterns;\n // If pattern were provided to the specific instance of the tester, use them\n if (customPatterns && !isEmpty(customPatterns)) {\n customPatterns.map((customPattern) => {\n const rootDirs = this.opts.roots || [patternEntry.componentDir];\n return this.resolvePattern(customPattern, rootDirs);\n });\n }\n return patternEntry.paths.map((p) => p.path);\n }\n\n private resolvePattern(pattern: string, rootDirs: string[]) {\n return rootDirs.map((dir) => resolve(dir, pattern));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EA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AAG,IAAK,IAAAhD,eAAO,EAACgD,GAAG,EAAED,OAAO,CAAC,CAAC;EACrD;AACF;AAAC"}
@@ -1,51 +1,39 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.promise.js");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.JestWorker = void 0;
11
-
12
9
  function _defineProperty2() {
13
10
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
-
15
11
  _defineProperty2 = function () {
16
12
  return data;
17
13
  };
18
-
19
14
  return data;
20
15
  }
21
-
22
16
  function _flatted() {
23
17
  const data = require("flatted");
24
-
25
18
  _flatted = function () {
26
19
  return data;
27
20
  };
28
-
29
21
  return data;
30
22
  }
31
-
32
23
  function _worker() {
33
24
  const data = require("@teambit/worker");
34
-
35
25
  _worker = function () {
36
26
  return data;
37
27
  };
38
-
39
28
  return data;
40
29
  }
41
-
42
30
  class JestWorker {
43
31
  constructor() {
44
32
  (0, _defineProperty2().default)(this, "onTestCompleteCb", void 0);
45
33
  }
46
-
47
34
  onTestComplete(onTestComplete) {
48
- this.onTestCompleteCb = onTestComplete; // return this;
35
+ this.onTestCompleteCb = onTestComplete;
36
+ // return this;
49
37
  }
50
38
 
51
39
  watch(jestConfigPath, testFiles, rootPath, jestModulePath, envRootDir) {
@@ -55,13 +43,9 @@ class JestWorker {
55
43
  console.warn = function () {};
56
44
  /* The path to the jest config file. */
57
45
  // eslint-disable-next-line import/no-dynamic-require,global-require
58
-
59
-
60
- const jestConfig = require(jestConfigPath); // eslint-disable-next-line import/no-dynamic-require,global-require
61
-
62
-
46
+ const jestConfig = require(jestConfigPath);
47
+ // eslint-disable-next-line import/no-dynamic-require,global-require
63
48
  const jestModule = require(jestModulePath);
64
-
65
49
  const jestConfigWithSpecs = Object.assign(jestConfig, {
66
50
  testMatch: testFiles
67
51
  });
@@ -87,26 +71,24 @@ class JestWorker {
87
71
  specFiles: testFiles,
88
72
  onComplete: results => {
89
73
  if (!this.onTestCompleteCb) return;
90
-
91
74
  try {
92
75
  const json = (0, _flatted().parse)((0, _flatted().stringify)(results));
93
- this.onTestCompleteCb(json); // disable eslint because we want to catch error but not print it on worker
76
+ this.onTestCompleteCb(json);
77
+ // disable eslint because we want to catch error but not print it on worker
94
78
  // eslint-disable-next-line
95
79
  } catch (error) {}
96
80
  }
97
81
  }]]
98
82
  };
99
- const withEnv = Object.assign(jestConfigWithSpecs, config); // eslint-disable-next-line @typescript-eslint/no-floating-promises
100
-
101
- const res = jestModule.runCLI(withEnv, [jestConfigPath]); // eslint-disable-next-line no-console
102
-
83
+ const withEnv = Object.assign(jestConfigWithSpecs, config);
84
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
85
+ const res = jestModule.runCLI(withEnv, [jestConfigPath]);
86
+ // eslint-disable-next-line no-console
103
87
  res.catch(err => console.error(err));
104
88
  resolve();
105
89
  });
106
90
  }
107
-
108
91
  }
109
-
110
92
  exports.JestWorker = JestWorker;
111
93
  (0, _worker().expose)(new JestWorker());
112
94
 
@@ -1 +1 @@
1
- {"version":3,"names":["JestWorker","onTestComplete","onTestCompleteCb","watch","jestConfigPath","testFiles","rootPath","jestModulePath","envRootDir","Promise","resolve","console","warn","jestConfig","require","jestModule","jestConfigWithSpecs","Object","assign","testMatch","config","rootDir","roots","runInBand","silent","watchAll","watchPlugins","__dirname","specFiles","onComplete","results","json","parse","stringify","error","withEnv","res","runCLI","catch","err","expose"],"sources":["jest.worker.ts"],"sourcesContent":["import { stringify, parse } from 'flatted';\nimport { expose } from '@teambit/worker';\nimport type jest from 'jest';\n\nexport class JestWorker {\n private onTestCompleteCb;\n\n onTestComplete(onTestComplete) {\n this.onTestCompleteCb = onTestComplete;\n // return this;\n }\n\n watch(\n jestConfigPath: string,\n testFiles: string[],\n rootPath: string,\n jestModulePath: string,\n envRootDir: string\n ): Promise<void> {\n return new Promise((resolve) => {\n // TODO: remove this after jest publish new version to npm: https://github.com/facebook/jest/pull/10804\n // eslint-disable-next-line\n console.warn = function () {};\n /* The path to the jest config file. */\n // eslint-disable-next-line import/no-dynamic-require,global-require\n const jestConfig = require(jestConfigPath);\n // eslint-disable-next-line import/no-dynamic-require,global-require\n const jestModule: typeof jest = require(jestModulePath);\n\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: testFiles,\n });\n\n const config: any = {\n // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins\n // from the env context\n rootDir: envRootDir,\n // Setting the roots (where to search for spec files) to the root path (either workspace or capsule root)\n // TODO: consider change this to be an array of the components running dir.\n // TODO: aka: in the workspace it will be something like <ws>/node_modules/<comp-package-name>/node_modules/<comp-package-name>\n // TODO: see dependencyResolver.getRuntimeModulePath (this will make sure the peer deps resolved correctly)\n // TODO: (@GiladShoham - when trying to set it to this paths, jest ignores it probably because the paths contains \"node_modules\"\n // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)\n // TODO: didn't help)\n roots: [rootPath],\n // useStderr: true,\n // TODO: check way to enable it\n runInBand: true,\n silent: false,\n watch: true,\n watchAll: true,\n watchPlugins: [\n [\n `${__dirname}/watch.js`,\n {\n specFiles: testFiles,\n onComplete: (results) => {\n if (!this.onTestCompleteCb) return;\n try {\n const json = parse(stringify(results));\n this.onTestCompleteCb(json);\n // disable eslint because we want to catch error but not print it on worker\n // eslint-disable-next-line\n } catch (error: any) {}\n },\n },\n ],\n ],\n };\n\n const withEnv = Object.assign(jestConfigWithSpecs, config);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n const res = jestModule.runCLI(withEnv, [jestConfigPath]);\n // eslint-disable-next-line no-console\n res.catch((err) => console.error(err));\n resolve();\n });\n }\n}\n\nexpose(new JestWorker());\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA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ADY;MAlBI,CAApB;MAqCA,MAAMC,OAAO,GAAGlB,MAAM,CAACC,MAAP,CAAcF,mBAAd,EAAmCI,MAAnC,CAAhB,CAnD8B,CAoD9B;;MACA,MAAMgB,GAAG,GAAGrB,UAAU,CAACsB,MAAX,CAAkBF,OAAlB,EAA2B,CAAC/B,cAAD,CAA3B,CAAZ,CArD8B,CAsD9B;;MACAgC,GAAG,CAACE,KAAJ,CAAWC,GAAD,IAAS5B,OAAO,CAACuB,KAAR,CAAcK,GAAd,CAAnB;MACA7B,OAAO;IACR,CAzDM,CAAP;EA0DD;;AAzEqB;;;AA4ExB,IAAA8B,gBAAA,EAAO,IAAIxC,UAAJ,EAAP"}
1
+ {"version":3,"names":["JestWorker","onTestComplete","onTestCompleteCb","watch","jestConfigPath","testFiles","rootPath","jestModulePath","envRootDir","Promise","resolve","console","warn","jestConfig","require","jestModule","jestConfigWithSpecs","Object","assign","testMatch","config","rootDir","roots","runInBand","silent","watchAll","watchPlugins","__dirname","specFiles","onComplete","results","json","parse","stringify","error","withEnv","res","runCLI","catch","err","expose"],"sources":["jest.worker.ts"],"sourcesContent":["import { stringify, parse } from 'flatted';\nimport { expose } from '@teambit/worker';\nimport type jest from 'jest';\n\nexport class JestWorker {\n private onTestCompleteCb;\n\n onTestComplete(onTestComplete) {\n this.onTestCompleteCb = onTestComplete;\n // return this;\n }\n\n watch(\n jestConfigPath: string,\n testFiles: string[],\n rootPath: string,\n jestModulePath: string,\n envRootDir: string\n ): Promise<void> {\n return new Promise((resolve) => {\n // TODO: remove this after jest publish new version to npm: https://github.com/facebook/jest/pull/10804\n // eslint-disable-next-line\n console.warn = function () {};\n /* The path to the jest config file. */\n // eslint-disable-next-line import/no-dynamic-require,global-require\n const jestConfig = require(jestConfigPath);\n // eslint-disable-next-line import/no-dynamic-require,global-require\n const jestModule: typeof jest = require(jestModulePath);\n\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: testFiles,\n });\n\n const config: any = {\n // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins\n // from the env context\n rootDir: envRootDir,\n // Setting the roots (where to search for spec files) to the root path (either workspace or capsule root)\n // TODO: consider change this to be an array of the components running dir.\n // TODO: aka: in the workspace it will be something like <ws>/node_modules/<comp-package-name>/node_modules/<comp-package-name>\n // TODO: see dependencyResolver.getRuntimeModulePath (this will make sure the peer deps resolved correctly)\n // TODO: (@GiladShoham - when trying to set it to this paths, jest ignores it probably because the paths contains \"node_modules\"\n // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)\n // TODO: didn't help)\n roots: [rootPath],\n // useStderr: true,\n // TODO: check way to enable it\n runInBand: true,\n silent: false,\n watch: true,\n watchAll: true,\n watchPlugins: [\n [\n `${__dirname}/watch.js`,\n {\n specFiles: testFiles,\n onComplete: (results) => {\n if (!this.onTestCompleteCb) return;\n try {\n const json = parse(stringify(results));\n this.onTestCompleteCb(json);\n // disable eslint because we want to catch error but not print it on worker\n // eslint-disable-next-line\n } catch (error: any) {}\n },\n },\n ],\n ],\n };\n\n const withEnv = Object.assign(jestConfigWithSpecs, config);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n const res = jestModule.runCLI(withEnv, [jestConfigPath]);\n // eslint-disable-next-line no-console\n res.catch((err) => console.error(err));\n resolve();\n });\n }\n}\n\nexpose(new JestWorker());\n"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,MAAMA,UAAU,CAAC;EAAA;IAAA;EAAA;EAGtBC,cAAc,CAACA,cAAc,EAAE;IAC7B,IAAI,CAACC,gBAAgB,GAAGD,cAAc;IACtC;EACF;;EAEAE,KAAK,CACHC,cAAsB,EACtBC,SAAmB,EACnBC,QAAgB,EAChBC,cAAsB,EACtBC,UAAkB,EACH;IACf,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;MAC9B;MAC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AACF;AAAC;AAED,IAAA8B,gBAAM,EAAC,IAAIxC,UAAU,EAAE,CAAC"}
package/dist/watch.js CHANGED
@@ -1,19 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  function _defineProperty2() {
8
6
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
-
10
7
  _defineProperty2 = function () {
11
8
  return data;
12
9
  };
13
-
14
10
  return data;
15
11
  }
16
-
17
12
  class Watch {
18
13
  constructor({
19
14
  stdin,
@@ -32,30 +27,26 @@ class Watch {
32
27
  this._specFiles = config.specFiles;
33
28
  this._onComplete = config.onComplete;
34
29
  }
35
-
36
30
  findComponent(specFile) {
37
31
  const component = this._specFiles.toArray().find(([, specs]) => {
38
32
  const paths = specs.map(spec => spec.path);
39
33
  if (paths.includes(specFile)) return true;
40
34
  return false;
41
35
  });
42
-
43
36
  return component === null || component === void 0 ? void 0 : component[0];
44
37
  }
45
-
46
38
  apply(jestHooks) {
47
39
  // jestHooks.shouldRunTestSuite(async (testSuite) => {
48
40
  // const component = this.findComponent(testSuite.testPath);
49
41
  // if ((await component?.isModified()) || (await component?.isNew())) return true;
50
42
  // return false;
51
43
  // });
44
+
52
45
  jestHooks.onTestRunComplete(results => {
53
46
  this._onComplete(results);
54
47
  });
55
48
  }
56
-
57
49
  }
58
-
59
50
  module.exports = Watch;
60
51
 
61
52
  //# sourceMappingURL=watch.js.map
package/dist/watch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Watch","constructor","stdin","stdout","config","_stdin","_stdout","_specFiles","specFiles","_onComplete","onComplete","findComponent","specFile","component","toArray","find","specs","paths","map","spec","path","includes","apply","jestHooks","onTestRunComplete","results","module","exports"],"sources":["watch.ts"],"sourcesContent":["import { Prompt, WatchPlugin, JestHookSubscriber, UsageData } from 'jest-watcher';\nimport { SpecFiles } from '@teambit/tester';\n\nexport type PluginConfig = {\n onComplete: (testSuite: any) => void;\n specFiles: SpecFiles;\n};\n\nclass Watch implements WatchPlugin {\n _stdin: NodeJS.ReadStream;\n\n _stdout: NodeJS.WriteStream;\n\n _prompt: Prompt;\n\n _testResults: any;\n\n _usageInfo: UsageData;\n\n _specFiles: SpecFiles;\n\n _onComplete: (testSuite: any) => void;\n\n constructor({\n stdin,\n stdout,\n config,\n }: {\n stdin: NodeJS.ReadStream;\n stdout: NodeJS.WriteStream;\n config: PluginConfig;\n }) {\n this._stdin = stdin;\n this._stdout = stdout;\n this._specFiles = config.specFiles;\n this._onComplete = config.onComplete;\n }\n\n private findComponent(specFile: string) {\n const component = this._specFiles.toArray().find(([, specs]) => {\n const paths = specs.map((spec) => spec.path);\n if (paths.includes(specFile)) return true;\n return false;\n });\n return component?.[0];\n }\n\n apply(jestHooks: JestHookSubscriber) {\n // jestHooks.shouldRunTestSuite(async (testSuite) => {\n // const component = this.findComponent(testSuite.testPath);\n // if ((await component?.isModified()) || (await component?.isNew())) return true;\n // return false;\n // });\n\n jestHooks.onTestRunComplete((results) => {\n this._onComplete(results);\n });\n }\n}\n\nmodule.exports = Watch;\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,MAAMA,KAAN,CAAmC;EAejCC,WAAW,CAAC;IACVC,KADU;IAEVC,MAFU;IAGVC;EAHU,CAAD,EAQR;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACD,KAAKC,MAAL,GAAcH,KAAd;IACA,KAAKI,OAAL,GAAeH,MAAf;IACA,KAAKI,UAAL,GAAkBH,MAAM,CAACI,SAAzB;IACA,KAAKC,WAAL,GAAmBL,MAAM,CAACM,UAA1B;EACD;;EAEOC,aAAa,CAACC,QAAD,EAAmB;IACtC,MAAMC,SAAS,GAAG,KAAKN,UAAL,CAAgBO,OAAhB,GAA0BC,IAA1B,CAA+B,CAAC,GAAGC,KAAH,CAAD,KAAe;MAC9D,MAAMC,KAAK,GAAGD,KAAK,CAACE,GAAN,CAAWC,IAAD,IAAUA,IAAI,CAACC,IAAzB,CAAd;MACA,IAAIH,KAAK,CAACI,QAAN,CAAeT,QAAf,CAAJ,EAA8B,OAAO,IAAP;MAC9B,OAAO,KAAP;IACD,CAJiB,CAAlB;;IAKA,OAAOC,SAAP,aAAOA,SAAP,uBAAOA,SAAS,CAAG,CAAH,CAAhB;EACD;;EAEDS,KAAK,CAACC,SAAD,EAAgC;IACnC;IACA;IACA;IACA;IACA;IAEAA,SAAS,CAACC,iBAAV,CAA6BC,OAAD,IAAa;MACvC,KAAKhB,WAAL,CAAiBgB,OAAjB;IACD,CAFD;EAGD;;AAjDgC;;AAoDnCC,MAAM,CAACC,OAAP,GAAiB3B,KAAjB"}
1
+ {"version":3,"names":["Watch","constructor","stdin","stdout","config","_stdin","_stdout","_specFiles","specFiles","_onComplete","onComplete","findComponent","specFile","component","toArray","find","specs","paths","map","spec","path","includes","apply","jestHooks","onTestRunComplete","results","module","exports"],"sources":["watch.ts"],"sourcesContent":["import { Prompt, WatchPlugin, JestHookSubscriber, UsageData } from 'jest-watcher';\nimport { SpecFiles } from '@teambit/tester';\n\nexport type PluginConfig = {\n onComplete: (testSuite: any) => void;\n specFiles: SpecFiles;\n};\n\nclass Watch implements WatchPlugin {\n _stdin: NodeJS.ReadStream;\n\n _stdout: NodeJS.WriteStream;\n\n _prompt: Prompt;\n\n _testResults: any;\n\n _usageInfo: UsageData;\n\n _specFiles: SpecFiles;\n\n _onComplete: (testSuite: any) => void;\n\n constructor({\n stdin,\n stdout,\n config,\n }: {\n stdin: NodeJS.ReadStream;\n stdout: NodeJS.WriteStream;\n config: PluginConfig;\n }) {\n this._stdin = stdin;\n this._stdout = stdout;\n this._specFiles = config.specFiles;\n this._onComplete = config.onComplete;\n }\n\n private findComponent(specFile: string) {\n const component = this._specFiles.toArray().find(([, specs]) => {\n const paths = specs.map((spec) => spec.path);\n if (paths.includes(specFile)) return true;\n return false;\n });\n return component?.[0];\n }\n\n apply(jestHooks: JestHookSubscriber) {\n // jestHooks.shouldRunTestSuite(async (testSuite) => {\n // const component = this.findComponent(testSuite.testPath);\n // if ((await component?.isModified()) || (await component?.isNew())) return true;\n // return false;\n // });\n\n jestHooks.onTestRunComplete((results) => {\n this._onComplete(results);\n });\n }\n}\n\nmodule.exports = Watch;\n"],"mappings":";;;;;;;;;;;AAQA,MAAMA,KAAK,CAAwB;EAejCC,WAAW,CAAC;IACVC,KAAK;IACLC,MAAM;IACNC;EAKF,CAAC,EAAE;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IACD,IAAI,CAACC,MAAM,GAAGH,KAAK;IACnB,IAAI,CAACI,OAAO,GAAGH,MAAM;IACrB,IAAI,CAACI,UAAU,GAAGH,MAAM,CAACI,SAAS;IAClC,IAAI,CAACC,WAAW,GAAGL,MAAM,CAACM,UAAU;EACtC;EAEQC,aAAa,CAACC,QAAgB,EAAE;IACtC,MAAMC,SAAS,GAAG,IAAI,CAACN,UAAU,CAACO,OAAO,EAAE,CAACC,IAAI,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAK;MAC9D,MAAMC,KAAK,GAAGD,KAAK,CAACE,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,CAAC;MAC5C,IAAIH,KAAK,CAACI,QAAQ,CAACT,QAAQ,CAAC,EAAE,OAAO,IAAI;MACzC,OAAO,KAAK;IACd,CAAC,CAAC;IACF,OAAOC,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAG,CAAC,CAAC;EACvB;EAEAS,KAAK,CAACC,SAA6B,EAAE;IACnC;IACA;IACA;IACA;IACA;;IAEAA,SAAS,CAACC,iBAAiB,CAAEC,OAAO,IAAK;MACvC,IAAI,CAAChB,WAAW,CAACgB,OAAO,CAAC;IAC3B,CAAC,CAAC;EACJ;AACF;AAEAC,MAAM,CAACC,OAAO,GAAG3B,KAAK"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/jest",
3
- "version": "0.0.881",
3
+ "version": "0.0.883",
4
4
  "homepage": "https://bit.dev/teambit/defender/jest",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.defender",
8
8
  "name": "jest",
9
- "version": "0.0.881"
9
+ "version": "0.0.883"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -22,11 +22,11 @@
22
22
  "@teambit/harmony": "0.3.3",
23
23
  "@teambit/cli": "0.0.591",
24
24
  "@teambit/logger": "0.0.684",
25
- "@teambit/worker": "0.0.881",
26
- "@teambit/component": "0.0.881",
27
- "@teambit/dependency-resolver": "0.0.881",
28
- "@teambit/envs": "0.0.881",
29
- "@teambit/tester": "0.0.881",
25
+ "@teambit/worker": "0.0.883",
26
+ "@teambit/component": "0.0.883",
27
+ "@teambit/dependency-resolver": "0.0.883",
28
+ "@teambit/envs": "0.0.883",
29
+ "@teambit/tester": "0.0.883",
30
30
  "@teambit/tests-results": "0.0.103"
31
31
  },
32
32
  "devDependencies": {
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.881/dist/jest.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.881/dist/jest.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.883/dist/jest.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.883/dist/jest.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];