@teambit/jest 0.0.649 → 0.0.653

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 +1 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.649/dist/jest.composition.js')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_jest@0.0.653/dist/jest.composition.js')]
@@ -236,15 +236,26 @@ class JestTester {
236
236
  testMatch: this.patternsToArray(context.patterns)
237
237
  });
238
238
  const withEnv = Object.assign(jestConfigWithSpecs, config);
239
- const testsOutPut = await this.jestModule.runCLI(withEnv, [this.jestConfig]);
240
- const testResults = testsOutPut.results.testResults;
241
- const componentsWithTests = this.attachTestsToComponent(context, testResults);
242
- const componentTestResults = this.buildTestsObj(testsOutPut.results, componentsWithTests, context, jestConfigWithSpecs);
243
- const globalErrors = this.getErrors(testResults);
244
- return {
245
- components: componentTestResults,
246
- errors: globalErrors
247
- };
239
+
240
+ try {
241
+ const testsOutPut = await this.jestModule.runCLI(withEnv, [this.jestConfig]);
242
+ const testResults = testsOutPut.results.testResults;
243
+ const componentsWithTests = this.attachTestsToComponent(context, testResults);
244
+ const componentTestResults = this.buildTestsObj(testsOutPut.results, componentsWithTests, context, jestConfigWithSpecs);
245
+ const globalErrors = this.getErrors(testResults);
246
+ return {
247
+ components: componentTestResults,
248
+ errors: globalErrors
249
+ };
250
+ } catch (e) {
251
+ const components = context.components.map(comp => ({
252
+ componentId: comp.id
253
+ }));
254
+ return {
255
+ components,
256
+ errors: [e]
257
+ };
258
+ }
248
259
  }
249
260
 
250
261
  async watch(context) {
@@ -1 +1 @@
1
- {"version":3,"sources":["jest.tester.ts"],"names":["JestTester","constructor","id","jestConfig","jestModulePath","jestWorker","logger","jestModule","require","displayConfig","version","getVersion","attachTestsToComponent","testerContext","testResult","ComponentMap","as","components","component","componentSpecFiles","patterns","get","undefined","specs","filter","test","pattern","testFilePath","path","length","buildTestsObj","aggregatedResult","config","testsSuiteResult","toArray","map","testsFiles","tests","file","AbstractVinyl","contents","testResults","error","noStackTrace","isFailure","status","TestResult","ancestorTitles","title","duration","filePath","basename","failureMessage","testExecError","message","TestsFiles","numPassingTests","numFailingTests","numPendingTests","perfStats","runtime","slow","componentId","results","TestsResult","success","startTime","getErrors","reduce","errors","stack","code","type","push","JestError","onTestRunComplete","callback","_callback","context","rootDir","rootPath","console","warn","debug","runInBand","coverage","watch","watchAll","noCache","jestConfigWithSpecs","Object","assign","testMatch","patternsToArray","withEnv","testsOutPut","runCLI","componentsWithTests","componentTestResults","globalErrors","Promise","resolve","workerApi","initiate","ui","stdout","stderr","stdin","cbFn","watchTestResults","loading","onTestComplete","err","p"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,UAAN,CAAmC;AAGxCC,EAAAA,WAAW,CACAC,EADA,EAEAC,UAFA,EAGDC,cAHC,EAIDC,UAJC,EAKDC,MALC,EAMT;AAAA,SALSJ,EAKT,GALSA,EAKT;AAAA,SAJSC,UAIT,GAJSA,UAIT;AAAA,SAHQC,cAGR,GAHQA,cAGR;AAAA,SAFQC,UAER,GAFQA,UAER;AAAA,SADQC,MACR,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c;AAEvBzC,YAAAA,MAAM,EAAE8B,YAFe;AAGvBlF,YAAAA,UAAU,EAAEiF;AAHW,WAAzB;;AAKA,eAAKrB,SAAL,CAAegC,gBAAf;;AACAR,UAAAA,OAAO,CAACQ,gBAAD,CAAP;AACD,SAbY,CAAb,CADE,CAgBF;;AACA,cAAMP,SAAS,CAACS,cAAV,CAAyBH,IAAzB,CAAN;AAEA,cAAMN,SAAS,CAAChB,KAAV,CACJ,KAAKnF,UADD,EAEJ,KAAK0F,eAAL,CAAqBf,OAAO,CAAC1D,QAA7B,CAFI,EAGJ0D,OAAO,CAACE,QAHJ,EAIJ,KAAK5E,cAJD,CAAN;AAMD,OAzBD,CAyBE,OAAO4G,GAAP,EAAiB;AACjB,aAAK1G,MAAL,CAAYoC,KAAZ,CAAkB,qCAAlB,EAAyDsE,GAAzD;AACD;AACF,KAxCM,CAAP;AAyCD;;AAEOnB,EAAAA,eAAe,CAACzE,QAAD,EAAiC;AACtD,WAAO,uBAAQA,QAAQ,CAACc,OAAT,GAAmBC,GAAnB,CAAuB,CAAC,GAAGT,OAAH,CAAD,KAAiBA,OAAO,CAACS,GAAR,CAAa8E,CAAD,IAAOA,CAAC,CAACrF,IAArB,CAAxC,CAAR,CAAP;AACD;;AAxMuC","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 } 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, ComponentID } 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 ) {\n const testsSuiteResult = components.toArray().map(([component, testsFiles]) => {\n if (!testsFiles) return;\n if (testsFiles?.length === 0) return;\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 error = {\n failureMessage: test.testExecError ? test.failureMessage : undefined,\n error: test.testExecError?.message,\n };\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 // TODO @guy - fix this eslint error\n // eslint-disable-next-line\n return {\n componentId: component.id,\n results: new TestsResult(tests, aggregatedResult.success, aggregatedResult.startTime),\n };\n });\n\n return compact(testsSuiteResult) as { componentId: ComponentID; results: TestsResult }[];\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 }\n 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 const globalErrors = this.getErrors(testResults);\n return { components: componentTestResults, errors: globalErrors };\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"]}
1
+ {"version":3,"sources":["jest.tester.ts"],"names":["JestTester","constructor","id","jestConfig","jestModulePath","jestWorker","logger","jestModule","require","displayConfig","version","getVersion","attachTestsToComponent","testerContext","testResult","ComponentMap","as","components","component","componentSpecFiles","patterns","get","undefined","specs","filter","test","pattern","testFilePath","path","length","buildTestsObj","aggregatedResult","config","testsSuiteResult","toArray","map","testsFiles","tests","file","AbstractVinyl","contents","testResults","error","noStackTrace","isFailure","status","TestResult","ancestorTitles","title","duration","filePath","basename","failureMessage","testExecError","message","TestsFiles","numPassingTests","numFailingTests","numPendingTests","perfStats","runtime","slow","componentId","results","TestsResult","success","startTime","getErrors","reduce","errors","stack","code","type","push","JestError","onTestRunComplete","callback","_callback","context","rootDir","rootPath","console","warn","debug","runInBand","coverage","watch","watchAll","noCache","jestConfigWithSpecs","Object","assign","testMatch","patternsToArray","withEnv","testsOutPut","runCLI","componentsWithTests","componentTestResults","globalErrors","e","comp","Promise","resolve","workerApi","initiate","ui","stdout","stderr","stdin","cbFn","watchTestResults","loading","onTestComplete","err","p"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,UAAN,CAAmC;AAGxCC,EAAAA,WAAW,CACAC,EADA,EAEAC,UAFA,EAGDC,cAHC,EAIDC,UAJC,EAKDC,MALC,EAMT;AAAA,SALSJ,EAKT,GALSA,EAKT;AAAA,SAJSC,UAIT,GAJSA,UAIT;AAAA,SAHQC,cAGR,GAHQA,cAGR;AAAA,SAFQC,UAER,GAFQA,UAER;AAAA,SADQC,MACR,GADQA,MACR;AAAA;AAAA,wDAKW,KAAKH,UALhB;AAAA,yDAOY,MAPZ;AAAA;AACA;AACA,SAAKI,UAAL,GAAkBC,OAAO,CAACJ,cAAD,CAAzB;AACD;;AAQDK,EAAAA,aAAa,GAAG;AACd,WAAO,6BAAa,KAAKN,UAAlB,EAA8B,MAA9B,CAAP;AACD;;AAEDO,EAAAA,OAAO,GAAG;AACR,WAAO,KAAKH,UAAL,CAAgBI,UAAhB,EAAP;AACD,GA1BuC,CA4BxC;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEQC,EAAAA,sBAAsB,CAACC,aAAD,EAA+BC,UAA/B,EAA6D;AACzF,WAAOC,0BAAaC,EAAb,C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OAAO,CAACQ,gBAAD,CAAP;AACD,SAbY,CAAb,CADE,CAgBF;;AACA,cAAMP,SAAS,CAACS,cAAV,CAAyBH,IAAzB,CAAN;AAEA,cAAMN,SAAS,CAAClB,KAAV,CACJ,KAAKnF,UADD,EAEJ,KAAK0F,eAAL,CAAqBf,OAAO,CAAC1D,QAA7B,CAFI,EAGJ0D,OAAO,CAACE,QAHJ,EAIJ,KAAK5E,cAJD,CAAN;AAMD,OAzBD,CAyBE,OAAO8G,GAAP,EAAiB;AACjB,aAAK5G,MAAL,CAAYoC,KAAZ,CAAkB,qCAAlB,EAAyDwE,GAAzD;AACD;AACF,KAxCM,CAAP;AAyCD;;AAEOrB,EAAAA,eAAe,CAACzE,QAAD,EAAiC;AACtD,WAAO,uBAAQA,QAAQ,CAACc,OAAT,GAAmBC,GAAnB,CAAuB,CAAC,GAAGT,OAAH,CAAD,KAAiBA,OAAO,CAACS,GAAR,CAAagF,CAAD,IAAOA,CAAC,CAACvF,IAArB,CAAxC,CAAR,CAAP;AACD;;AA7MuC","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 } 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, ComponentID } 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 ) {\n const testsSuiteResult = components.toArray().map(([component, testsFiles]) => {\n if (!testsFiles) return;\n if (testsFiles?.length === 0) return;\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 error = {\n failureMessage: test.testExecError ? test.failureMessage : undefined,\n error: test.testExecError?.message,\n };\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 // TODO @guy - fix this eslint error\n // eslint-disable-next-line\n return {\n componentId: component.id,\n results: new TestsResult(tests, aggregatedResult.success, aggregatedResult.startTime),\n };\n });\n\n return compact(testsSuiteResult) as { componentId: ComponentID; results: TestsResult }[];\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 }\n 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 try {\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 const globalErrors = this.getErrors(testResults);\n return { components: componentTestResults, errors: globalErrors };\n } catch (e) {\n const components = context.components.map((comp) => ({ componentId: comp.id }));\n return { components, errors: [e as Error] };\n }\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"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/jest",
3
- "version": "0.0.649",
3
+ "version": "0.0.653",
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.649"
9
+ "version": "0.0.653"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
@@ -21,11 +21,11 @@
21
21
  "jest-watcher": "26.6.2",
22
22
  "@babel/runtime": "7.12.18",
23
23
  "core-js": "^3.0.0",
24
- "@teambit/cli": "0.0.443",
25
- "@teambit/logger": "0.0.533",
26
- "@teambit/worker": "0.0.649",
27
- "@teambit/component": "0.0.649",
28
- "@teambit/tester": "0.0.649",
24
+ "@teambit/cli": "0.0.445",
25
+ "@teambit/logger": "0.0.535",
26
+ "@teambit/worker": "0.0.653",
27
+ "@teambit/component": "0.0.653",
28
+ "@teambit/tester": "0.0.653",
29
29
  "@teambit/tests-results": "0.0.95"
30
30
  },
31
31
  "devDependencies": {
@@ -39,7 +39,7 @@
39
39
  "@types/node": "12.20.4"
40
40
  },
41
41
  "peerDependencies": {
42
- "@teambit/legacy": "1.0.221",
42
+ "@teambit/legacy": "1.0.223",
43
43
  "jest": "26.6.3",
44
44
  "react-dom": "^16.8.0 || ^17.0.0",
45
45
  "react": "^16.8.0 || ^17.0.0"