@teambit/jest 0.0.505 → 0.0.509
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jest.tester.js
CHANGED
|
@@ -166,8 +166,9 @@ class JestTester {
|
|
|
166
166
|
const testResults = test.testResults.map(testResult => {
|
|
167
167
|
const error = (0, _jestMessageUtil().formatResultsErrors)([testResult], config, {
|
|
168
168
|
noStackTrace: true
|
|
169
|
-
});
|
|
170
|
-
|
|
169
|
+
}) || undefined;
|
|
170
|
+
const isFailure = testResult.status === 'failed';
|
|
171
|
+
return new (_testsResults().TestResult)(testResult.ancestorTitles, testResult.title, testResult.status, testResult.duration, isFailure ? undefined : error, isFailure ? error : undefined);
|
|
171
172
|
});
|
|
172
173
|
const filePath = (file === null || file === void 0 ? void 0 : file.basename) || test.testFilePath;
|
|
173
174
|
const error = {
|
|
@@ -220,6 +221,7 @@ class JestTester {
|
|
|
220
221
|
};
|
|
221
222
|
|
|
222
223
|
if (context.debug) config.runInBand = true;
|
|
224
|
+
if (context.coverage) config.coverage = true;
|
|
223
225
|
config.runInBand = true;
|
|
224
226
|
|
|
225
227
|
if (context.watch) {
|
package/dist/jest.tester.js.map
CHANGED
|
@@ -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","TestResult","ancestorTitles","title","status","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","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,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;;;AA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A,eAAe,CAACvE,QAAD,EAAiC;AACtD,WAAO,uBAAQA,QAAQ,CAACc,OAAT,GAAmBC,GAAnB,CAAuB,CAAC,GAAGT,OAAH,CAAD,KAAiBA,OAAO,CAACS,GAAR,CAAa4E,CAAD,IAAOA,CAAC,CAACnF,IAArB,CAAxC,CAAR,CAAP;AACD;;AArMuC","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 });\n return new TestResult(\n testResult.ancestorTitles,\n testResult.title,\n testResult.status,\n testResult.duration,\n 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 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","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,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B,EAAiDnB,OAAjD,EAA0DW,mBAA1D,CAA7B;AACA,gBAAMU,YAAY,GAAG,KAAKhC,SAAL,CAAe1B,WAAf,CAArB;AACA,gBAAMoE,gBAAgB,GAAG;AACvBC,YAAAA,OAAO,EAAE,KADc;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"]}
|
package/jest.tester.ts
CHANGED
|
@@ -73,13 +73,15 @@ export class JestTester implements Tester {
|
|
|
73
73
|
const tests = testsFiles.map((test) => {
|
|
74
74
|
const file = new AbstractVinyl({ path: test.testFilePath, contents: readFileSync(test.testFilePath) });
|
|
75
75
|
const testResults = test.testResults.map((testResult) => {
|
|
76
|
-
const error = formatResultsErrors([testResult], config, { noStackTrace: true });
|
|
76
|
+
const error = formatResultsErrors([testResult], config, { noStackTrace: true }) || undefined;
|
|
77
|
+
const isFailure = testResult.status === 'failed';
|
|
77
78
|
return new TestResult(
|
|
78
79
|
testResult.ancestorTitles,
|
|
79
80
|
testResult.title,
|
|
80
81
|
testResult.status,
|
|
81
82
|
testResult.duration,
|
|
82
|
-
|
|
83
|
+
isFailure ? undefined : error,
|
|
84
|
+
isFailure ? error : undefined
|
|
83
85
|
);
|
|
84
86
|
});
|
|
85
87
|
const filePath = file?.basename || test.testFilePath;
|
|
@@ -137,6 +139,7 @@ export class JestTester implements Tester {
|
|
|
137
139
|
};
|
|
138
140
|
|
|
139
141
|
if (context.debug) config.runInBand = true;
|
|
142
|
+
if (context.coverage) config.coverage = true;
|
|
140
143
|
config.runInBand = true;
|
|
141
144
|
|
|
142
145
|
if (context.watch) {
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/jest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.509",
|
|
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.
|
|
9
|
+
"version": "0.0.509"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"@babel/runtime": "7.12.18",
|
|
23
23
|
"core-js": "^3.0.0",
|
|
24
24
|
"@teambit/cli": "0.0.378",
|
|
25
|
-
"@teambit/logger": "0.0.
|
|
26
|
-
"@teambit/worker": "0.0.
|
|
27
|
-
"@teambit/component": "0.0.
|
|
28
|
-
"@teambit/tester": "0.0.
|
|
29
|
-
"@teambit/tests-results": "0.0.
|
|
25
|
+
"@teambit/logger": "0.0.443",
|
|
26
|
+
"@teambit/worker": "0.0.509",
|
|
27
|
+
"@teambit/component": "0.0.509",
|
|
28
|
+
"@teambit/tester": "0.0.509",
|
|
29
|
+
"@teambit/tests-results": "0.0.65"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/fs-extra": "9.0.7",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/node": "12.20.4"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@teambit/legacy": "1.0.
|
|
42
|
+
"@teambit/legacy": "1.0.154",
|
|
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"
|
|
Binary file
|