@teambit/jest 0.0.800 → 0.0.803

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.
@@ -0,0 +1 @@
1
+ export declare function getRootDirFromConfigPath(configPath: string): string;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.regexp.exec.js");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getRootDirFromConfigPath = getRootDirFromConfigPath;
9
+
10
+ function _lodash() {
11
+ const data = require("lodash");
12
+
13
+ _lodash = function () {
14
+ return data;
15
+ };
16
+
17
+ return data;
18
+ }
19
+
20
+ function _path() {
21
+ const data = require("path");
22
+
23
+ _path = function () {
24
+ return data;
25
+ };
26
+
27
+ return data;
28
+ }
29
+
30
+ function getRootDirFromConfigPath(configPath) {
31
+ const splitted = configPath.split('node_modules');
32
+ const last = splitted[splitted.length - 1];
33
+ const lastSplitted = (0, _lodash().compact)(last.split(_path().sep));
34
+ let lastModule = lastSplitted[0];
35
+
36
+ if (lastSplitted[0].startsWith('@')) {
37
+ lastModule = (0, _path().join)(lastSplitted[0], lastSplitted[1]);
38
+ }
39
+
40
+ splitted[splitted.length - 1] = `${_path().sep}${lastModule}`;
41
+ const final = splitted.join('node_modules');
42
+ return final;
43
+ }
44
+
45
+ //# sourceMappingURL=calc-root-dir.js.map
@@ -0,0 +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"}
@@ -21,5 +21,6 @@ export declare class JestTester implements Tester {
21
21
  onTestRunComplete(callback: CallbackFn): Promise<void>;
22
22
  test(context: TesterContext): Promise<Tests>;
23
23
  watch(context: TesterContext): Promise<Tests>;
24
+ private calculateModuleNameMapper;
24
25
  private patternsToArray;
25
26
  }
@@ -111,6 +111,16 @@ function _sources() {
111
111
  return data;
112
112
  }
113
113
 
114
+ function _dependencyResolver() {
115
+ const data = require("@teambit/dependency-resolver");
116
+
117
+ _dependencyResolver = function () {
118
+ return data;
119
+ };
120
+
121
+ return data;
122
+ }
123
+
114
124
  function _error() {
115
125
  const data = require("./error");
116
126
 
@@ -142,14 +152,7 @@ class JestTester {
142
152
 
143
153
  version() {
144
154
  return this.jestModule.getVersion();
145
- } // private getTestFile(path: string, testerContext: TesterContext): AbstractVinyl | undefined {
146
- // return testerContext.specFiles.toArray().reduce((acc: AbstractVinyl | undefined, [, specs]) => {
147
- // const file = specs.find((spec) => spec.path === path);
148
- // if (file) acc = file;
149
- // return acc;
150
- // }, undefined);
151
- // }
152
-
155
+ }
153
156
 
154
157
  attachTestsToComponent(testerContext, testResult) {
155
158
  return _component().ComponentMap.as(testerContext.components, component => {
@@ -231,15 +234,30 @@ class JestTester {
231
234
  }
232
235
 
233
236
  async test(context) {
237
+ const envRootDir = context.envRuntime.envAspectDefinition.aspectPath;
234
238
  const config = {
235
- rootDir: context.rootPath
239
+ // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins
240
+ // from the env context
241
+ rootDir: envRootDir,
242
+ // Setting the roots (where to search for spec files) to the root path (either workspace or capsule root)
243
+ // TODO: consider change this to be an array of the components running dir.
244
+ // TODO: aka: in the workspace it will be something like <ws>/node_modules/<comp-package-name>/node_modules/<comp-package-name>
245
+ // TODO: see dependencyResolver.getRuntimeModulePath (this will make sure the peer deps resolved correctly)
246
+ // TODO: (@GiladShoham - when trying to set it to this paths, jest ignores it probably because the paths contains "node_modules"
247
+ // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)
248
+ // TODO: didn't help)
249
+ roots: [context.rootPath]
236
250
  }; // eslint-disable-next-line no-console
237
251
 
238
252
  console.warn = message => {
239
253
  this.logger.warn(message);
240
254
  };
241
255
 
242
- if (context.debug) config.runInBand = true;
256
+ if (context.debug) {
257
+ config.debug = true;
258
+ config.runInBand = true;
259
+ }
260
+
243
261
  if (context.coverage) config.coverage = true;
244
262
  config.runInBand = true;
245
263
 
@@ -251,6 +269,8 @@ class JestTester {
251
269
 
252
270
  const jestConfig = require(this.jestConfig);
253
271
 
272
+ const moduleNameMapper = await this.calculateModuleNameMapper(context.env, context.rootPath, context.additionalHostDependencies);
273
+ jestConfig.moduleNameMapper = Object.assign({}, jestConfig.moduleNameMapper || {}, moduleNameMapper);
254
274
  const jestConfigWithSpecs = Object.assign(jestConfig, {
255
275
  testMatch: this.patternsToArray(context.patterns)
256
276
  });
@@ -277,6 +297,7 @@ class JestTester {
277
297
 
278
298
  const jestConfig = require(this.jestConfig);
279
299
 
300
+ const envRootDir = context.envRuntime.envAspectDefinition.aspectPath;
280
301
  const jestConfigWithSpecs = Object.assign(jestConfig, {
281
302
  testMatch: this.patternsToArray(context.patterns)
282
303
  });
@@ -300,13 +321,33 @@ class JestTester {
300
321
  }); // eslint-disable-next-line @typescript-eslint/no-floating-promises
301
322
 
302
323
  await workerApi.onTestComplete(cbFn);
303
- await workerApi.watch(this.jestConfig, this.patternsToArray(context.patterns), context.rootPath, this.jestModulePath);
324
+ await workerApi.watch(this.jestConfig, this.patternsToArray(context.patterns), context.rootPath, this.jestModulePath, envRootDir);
304
325
  } catch (err) {
305
326
  this.logger.error('jest.tester.watch() caught an error', err);
306
327
  }
307
328
  });
308
329
  }
309
330
 
331
+ async calculateModuleNameMapper(env, rootPath, additionalHostDependencies) {
332
+ const peerDepsConfig = await env.getDependencies();
333
+ const peersAutoDetectPolicy = new (_dependencyResolver().PeersAutoDetectPolicy)(peerDepsConfig.peers || []);
334
+ const peers = Object.keys(peerDepsConfig.peerDependencies || {}).concat(peersAutoDetectPolicy === null || peersAutoDetectPolicy === void 0 ? void 0 : peersAutoDetectPolicy.names);
335
+ const depsToMap = peers.concat(additionalHostDependencies || []);
336
+ /**
337
+ * Try to resolve the dependency from the rootDir (the env dir) or from the root path (workspace/capsule root)
338
+ */
339
+
340
+ const mappedValues = ['<rootDir>/node_modules/$1', `${rootPath}/node_modules/$1`];
341
+ const moduleNameMapper = depsToMap.reduce((acc, peerName) => {
342
+ const keyName = `^(${peerName})$`;
343
+ acc[keyName] = mappedValues;
344
+ const internalPathKeyName = `^(${peerName}/.*)$`;
345
+ acc[internalPathKeyName] = mappedValues;
346
+ return acc;
347
+ }, {});
348
+ return moduleNameMapper;
349
+ }
350
+
310
351
  patternsToArray(patterns) {
311
352
  return (0, _lodash().flatten)(patterns.toArray().map(([, pattern]) => pattern.map(p => p.path)));
312
353
  }
@@ -1 +1 @@
1
- {"version":3,"names":["JestTester","constructor","id","jestConfig","jestModulePath","jestWorker","logger","jestModule","require","displayConfig","readFileSync","version","getVersion","attachTestsToComponent","testerContext","testResult","ComponentMap","as","components","component","componentSpecFiles","patterns","get","undefined","specs","filter","test","pattern","minimatch","testFilePath","path","length","buildTestsObj","aggregatedResult","config","testsSuiteResult","toArray","map","testsFiles","errors","getErrors","tests","file","AbstractVinyl","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","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","cbFn","proxy","globalErrors","watchTestResults","loading","onTestComplete","err","flatten","p"],"sources":["jest.tester.ts"],"sourcesContent":["import { readFileSync } from 'fs-extra';\nimport minimatch from 'minimatch';\nimport { compact, flatten } from 'lodash';\nimport { proxy } from 'comlink';\nimport { Logger } from '@teambit/logger';\nimport { HarmonyWorker } from '@teambit/worker';\nimport { Tester, CallbackFn, TesterContext, Tests, ComponentPatternsMap, ComponentsResults } 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 { ComponentMap } from '@teambit/component';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport type jest from 'jest';\nimport { JestError } from './error';\nimport type { JestWorker } from './jest.worker';\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 ) {\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 getTestFile(path: string, testerContext: TesterContext): AbstractVinyl | undefined {\n // return testerContext.specFiles.toArray().reduce((acc: AbstractVinyl | undefined, [, specs]) => {\n // const file = specs.find((spec) => spec.path === path);\n // if (file) acc = file;\n // return acc;\n // }, undefined);\n // }\n\n private attachTestsToComponent(testerContext: TesterContext, testResult: JestTestResult[]) {\n return ComponentMap.as(testerContext.components, (component) => {\n const componentSpecFiles = testerContext.patterns.get(component);\n if (!componentSpecFiles) return undefined;\n const [, specs] = componentSpecFiles;\n return testResult.filter((test) => {\n return specs.filter((pattern) => minimatch(test.testFilePath, pattern.path)).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 config: any = {\n rootDir: 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) config.runInBand = true;\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 const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context.patterns),\n });\n\n const withEnv = Object.assign(jestConfigWithSpecs, config);\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 jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context.patterns),\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.patterns),\n context.rootPath,\n this.jestModulePath\n );\n } catch (err: any) {\n this.logger.error('jest.tester.watch() caught an error', err);\n }\n });\n }\n\n private patternsToArray(patterns: ComponentPatternsMap) {\n return flatten(patterns.toArray().map(([, pattern]) => pattern.map((p) => p.path)));\n }\n}\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;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AA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xC,CAAR,CAAP;EACD;;AA7MuC"}
1
+ {"version":3,"names":["JestTester","constructor","id","jestConfig","jestModulePath","jestWorker","logger","jestModule","require","displayConfig","readFileSync","version","getVersion","attachTestsToComponent","testerContext","testResult","ComponentMap","as","components","component","componentSpecFiles","patterns","get","undefined","specs","filter","test","pattern","minimatch","testFilePath","path","length","buildTestsObj","aggregatedResult","config","testsSuiteResult","toArray","map","testsFiles","errors","getErrors","tests","file","AbstractVinyl","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","envRootDir","envRuntime","envAspectDefinition","aspectPath","rootDir","roots","rootPath","console","warn","debug","runInBand","coverage","watchAll","noCache","moduleNameMapper","calculateModuleNameMapper","env","additionalHostDependencies","Object","assign","jestConfigWithSpecs","testMatch","patternsToArray","withEnv","testsOutPut","runCLI","componentsWithTests","componentTestResults","Tests","Promise","resolve","workerApi","initiate","ui","stdout","stderr","stdin","cbFn","proxy","globalErrors","watchTestResults","loading","onTestComplete","err","peerDepsConfig","getDependencies","peersAutoDetectPolicy","PeersAutoDetectPolicy","peers","keys","peerDependencies","concat","names","depsToMap","mappedValues","acc","peerName","keyName","internalPathKeyName","flatten","p"],"sources":["jest.tester.ts"],"sourcesContent":["import { readFileSync } from 'fs-extra';\nimport minimatch from 'minimatch';\nimport { compact, flatten } from 'lodash';\nimport { proxy } from 'comlink';\nimport { Logger } from '@teambit/logger';\nimport { HarmonyWorker } from '@teambit/worker';\nimport { Tester, CallbackFn, TesterContext, Tests, ComponentPatternsMap, ComponentsResults } 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 { 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 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 ) {\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 componentSpecFiles = testerContext.patterns.get(component);\n if (!componentSpecFiles) return undefined;\n const [, specs] = componentSpecFiles;\n return testResult.filter((test) => {\n return specs.filter((pattern) => minimatch(test.testFilePath, pattern.path)).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 // 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 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.patterns),\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\n const jestConfigWithSpecs = Object.assign(jestConfig, {\n testMatch: this.patternsToArray(context.patterns),\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.patterns),\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(patterns: ComponentPatternsMap) {\n return flatten(patterns.toArray().map(([, pattern]) => pattern.map((p) => p.path)));\n }\n}\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;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;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,OAAO,IAAA2H,iBAAA,EAAQ3H,QAAQ,CAACe,OAAT,GAAmBC,GAAnB,CAAuB,CAAC,GAAGV,OAAH,CAAD,KAAiBA,OAAO,CAACU,GAAR,CAAa4G,CAAD,IAAOA,CAAC,CAACnH,IAArB,CAAxC,CAAR,CAAP;EACD;;AAzPuC"}
@@ -1,5 +1,5 @@
1
1
  export declare class JestWorker {
2
2
  private onTestCompleteCb;
3
3
  onTestComplete(onTestComplete: any): void;
4
- watch(jestConfigPath: string, testFiles: string[], rootPath: string, jestModulePath: string): Promise<void>;
4
+ watch(jestConfigPath: string, testFiles: string[], rootPath: string, jestModulePath: string, envRootDir: string): Promise<void>;
5
5
  }
@@ -48,11 +48,13 @@ class JestWorker {
48
48
  this.onTestCompleteCb = onTestComplete; // return this;
49
49
  }
50
50
 
51
- watch(jestConfigPath, testFiles, rootPath, jestModulePath) {
51
+ watch(jestConfigPath, testFiles, rootPath, jestModulePath, envRootDir) {
52
52
  return new Promise(resolve => {
53
53
  // TODO: remove this after jest publish new version to npm: https://github.com/facebook/jest/pull/10804
54
54
  // eslint-disable-next-line
55
- console.warn = function () {}; // eslint-disable-next-line import/no-dynamic-require,global-require
55
+ console.warn = function () {};
56
+ /* The path to the jest config file. */
57
+ // eslint-disable-next-line import/no-dynamic-require,global-require
56
58
 
57
59
 
58
60
  const jestConfig = require(jestConfigPath); // eslint-disable-next-line import/no-dynamic-require,global-require
@@ -64,11 +66,21 @@ class JestWorker {
64
66
  testMatch: testFiles
65
67
  });
66
68
  const config = {
69
+ // Setting the rootDir to the env root dir to make sure we can resolve all the jest presets/plugins
70
+ // from the env context
71
+ rootDir: envRootDir,
72
+ // Setting the roots (where to search for spec files) to the root path (either workspace or capsule root)
73
+ // TODO: consider change this to be an array of the components running dir.
74
+ // TODO: aka: in the workspace it will be something like <ws>/node_modules/<comp-package-name>/node_modules/<comp-package-name>
75
+ // TODO: see dependencyResolver.getRuntimeModulePath (this will make sure the peer deps resolved correctly)
76
+ // TODO: (@GiladShoham - when trying to set it to this paths, jest ignores it probably because the paths contains "node_modules"
77
+ // TODO: trying to set the https://jestjs.io/docs/27.x/configuration#testpathignorepatterns-arraystring to something else (as it contain node_modules by default)
78
+ // TODO: didn't help)
79
+ roots: [rootPath],
67
80
  // useStderr: true,
68
81
  // TODO: check way to enable it
69
82
  runInBand: true,
70
83
  silent: false,
71
- rootDir: rootPath,
72
84
  watch: true,
73
85
  watchAll: true,
74
86
  watchPlugins: [[`${__dirname}/watch.js`, {
@@ -1 +1 @@
1
- {"version":3,"names":["JestWorker","onTestComplete","onTestCompleteCb","watch","jestConfigPath","testFiles","rootPath","jestModulePath","Promise","resolve","console","warn","jestConfig","require","jestModule","jestConfigWithSpecs","Object","assign","testMatch","config","runInBand","silent","rootDir","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(jestConfigPath: string, testFiles: string[], rootPath: string, jestModulePath: string): 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 // 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 // useStderr: true,\n // TODO: check way to enable it\n runInBand: true,\n silent: false,\n rootDir: rootPath,\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,UAAN,CAAiB;EAAA;IAAA;EAAA;;EAGtBC,cAAc,CAACA,cAAD,EAAiB;IAC7B,KAAKC,gBAAL,GAAwBD,cAAxB,CAD6B,CAE7B;EACD;;EAEDE,KAAK,CAACC,cAAD,EAAyBC,SAAzB,EAA8CC,QAA9C,EAAgEC,cAAhE,EAAuG;IAC1G,OAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAa;MAC9B;MACA;MACAC,OAAO,CAACC,IAAR,GAAe,YAAY,CAAE,CAA7B,CAH8B,CAI9B;;;MACA,MAAMC,UAAU,GAAGC,OAAO,CAACT,cAAD,CAA1B,CAL8B,CAM9B;;;MACA,MAAMU,UAAuB,GAAGD,OAAO,CAACN,cAAD,CAAvC;;MAEA,MAAMQ,mBAAmB,GAAGC,MAAM,CAACC,MAAP,CAAcL,UAAd,EAA0B;QACpDM,SAAS,EAAEb;MADyC,CAA1B,CAA5B;MAIA,MAAMc,MAAW,GAAG;QAClB;QACA;QACAC,SAAS,EAAE,IAHO;QAIlBC,MAAM,EAAE,KAJU;QAKlBC,OAAO,EAAEhB,QALS;QAMlBH,KAAK,EAAE,IANW;QAOlBoB,QAAQ,EAAE,IAPQ;QAQlBC,YAAY,EAAE,CACZ,CACG,GAAEC,SAAU,WADf,EAEE;UACEC,SAAS,EAAErB,SADb;UAEEsB,UAAU,EAAGC,OAAD,IAAa;YACvB,IAAI,CAAC,KAAK1B,gBAAV,EAA4B;;YAC5B,IAAI;cACF,MAAM2B,IAAI,GAAG,IAAAC,gBAAA,EAAM,IAAAC,oBAAA,EAAUH,OAAV,CAAN,CAAb;cACA,KAAK1B,gBAAL,CAAsB2B,IAAtB,EAFE,CAGF;cACA;YACD,CALD,CAKE,OAAOG,KAAP,EAAmB,CAAE;UACxB;QAVH,CAFF,CADY;MARI,CAApB;MA2BA,MAAMC,OAAO,GAAGjB,MAAM,CAACC,MAAP,CAAcF,mBAAd,EAAmCI,MAAnC,CAAhB,CAxC8B,CAyC9B;;MACA,MAAMe,GAAG,GAAGpB,UAAU,CAACqB,MAAX,CAAkBF,OAAlB,EAA2B,CAAC7B,cAAD,CAA3B,CAAZ,CA1C8B,CA2C9B;;MACA8B,GAAG,CAACE,KAAJ,CAAWC,GAAD,IAAS3B,OAAO,CAACsB,KAAR,CAAcK,GAAd,CAAnB;MACA5B,OAAO;IACR,CA9CM,CAAP;EA+CD;;AAxDqB;;;AA2DxB,IAAA6B,gBAAA,EAAO,IAAItC,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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AFF,CADY;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"}
package/package.json CHANGED
@@ -1,37 +1,38 @@
1
1
  {
2
2
  "name": "@teambit/jest",
3
- "version": "0.0.800",
3
+ "version": "0.0.803",
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.800"
9
+ "version": "0.0.803"
10
10
  },
11
11
  "dependencies": {
12
+ "lodash": "4.17.21",
12
13
  "@jest/test-result": "26.6.2",
13
14
  "comlink": "4.3.0",
14
15
  "fs-extra": "10.0.0",
15
16
  "jest-message-util": "27.5.1",
16
- "jest": "27.5.1",
17
- "lodash": "4.17.21",
18
17
  "minimatch": "3.0.4",
19
18
  "flatted": "3.1.0",
20
19
  "jest-watcher": "27.5.1",
21
20
  "@babel/runtime": "7.12.18",
22
21
  "core-js": "^3.0.0",
23
22
  "@teambit/harmony": "0.3.3",
24
- "@teambit/cli": "0.0.532",
25
- "@teambit/logger": "0.0.625",
26
- "@teambit/worker": "0.0.800",
27
- "@teambit/component": "0.0.800",
28
- "@teambit/tester": "0.0.800",
23
+ "@teambit/cli": "0.0.535",
24
+ "@teambit/logger": "0.0.628",
25
+ "@teambit/worker": "0.0.803",
26
+ "@teambit/component": "0.0.803",
27
+ "@teambit/dependency-resolver": "0.0.803",
28
+ "@teambit/envs": "0.0.803",
29
+ "@teambit/tester": "0.0.803",
29
30
  "@teambit/tests-results": "0.0.97"
30
31
  },
31
32
  "devDependencies": {
33
+ "@types/lodash": "4.14.165",
32
34
  "@types/react": "^17.0.8",
33
35
  "@types/fs-extra": "9.0.7",
34
- "@types/lodash": "4.14.165",
35
36
  "@types/minimatch": "3.0.4",
36
37
  "@types/testing-library__jest-dom": "5.9.5",
37
38
  "@types/jest": "^26.0.0",
@@ -39,7 +40,7 @@
39
40
  "@types/node": "12.20.4"
40
41
  },
41
42
  "peerDependencies": {
42
- "@teambit/legacy": "1.0.314",
43
+ "@teambit/legacy": "1.0.317",
43
44
  "jest": "27.5.1",
44
45
  "react-dom": "^16.8.0 || ^17.0.0",
45
46
  "react": "^16.8.0 || ^17.0.0"
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.800/dist/jest.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.800/dist/jest.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.803/dist/jest.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.803/dist/jest.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];