@teambit/jest 0.0.553 → 0.0.557
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/package.json +17 -9
- package/tsconfig.json +1 -2
- package/error.ts +0 -9
- package/index.ts +0 -3
- package/jest.aspect.ts +0 -5
- package/jest.composition.tsx +0 -7
- package/jest.main.runtime.ts +0 -27
- package/jest.tester.ts +0 -218
- package/jest.worker.ts +0 -64
- package/package-tar/teambit-jest-0.0.553.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/watch.ts +0 -61
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/jest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.557",
|
|
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.557"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
@@ -21,12 +21,12 @@
|
|
|
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.
|
|
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.
|
|
24
|
+
"@teambit/cli": "0.0.388",
|
|
25
|
+
"@teambit/logger": "0.0.473",
|
|
26
|
+
"@teambit/worker": "0.0.557",
|
|
27
|
+
"@teambit/component": "0.0.557",
|
|
28
|
+
"@teambit/tester": "0.0.557",
|
|
29
|
+
"@teambit/tests-results": "0.0.74"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/react": "^17.0.8",
|
|
@@ -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.174",
|
|
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"
|
|
@@ -72,6 +72,14 @@
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
+
"files": [
|
|
76
|
+
"dist",
|
|
77
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
78
|
+
"README.md",
|
|
79
|
+
"README.mdx",
|
|
80
|
+
"*.js",
|
|
81
|
+
"*.json"
|
|
82
|
+
],
|
|
75
83
|
"private": false,
|
|
76
84
|
"engines": {
|
|
77
85
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"strict": true,
|
|
26
26
|
"noImplicitAny": false,
|
|
27
27
|
"rootDir": ".",
|
|
28
|
-
"removeComments": true,
|
|
29
28
|
"preserveConstEnums": true,
|
|
30
29
|
"resolveJsonModule": true
|
|
31
30
|
},
|
package/error.ts
DELETED
package/index.ts
DELETED
package/jest.aspect.ts
DELETED
package/jest.composition.tsx
DELETED
package/jest.main.runtime.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MainRuntime } from '@teambit/cli';
|
|
2
|
-
import { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';
|
|
3
|
-
import { WorkerAspect, WorkerMain, HarmonyWorker } from '@teambit/worker';
|
|
4
|
-
import { JestAspect } from './jest.aspect';
|
|
5
|
-
import { JestTester } from './jest.tester';
|
|
6
|
-
import type { JestWorker } from './jest.worker';
|
|
7
|
-
|
|
8
|
-
export const WORKER_NAME = 'jest';
|
|
9
|
-
|
|
10
|
-
export class JestMain {
|
|
11
|
-
constructor(private jestWorker: HarmonyWorker<JestWorker>, private logger: Logger) {}
|
|
12
|
-
|
|
13
|
-
createTester(jestConfig: any, jestModulePath = require.resolve('jest')) {
|
|
14
|
-
return new JestTester(JestAspect.id, jestConfig, jestModulePath, this.jestWorker, this.logger);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static runtime = MainRuntime;
|
|
18
|
-
static dependencies = [WorkerAspect, LoggerAspect];
|
|
19
|
-
|
|
20
|
-
static async provider([worker, loggerAspect]: [WorkerMain, LoggerMain]) {
|
|
21
|
-
const logger = loggerAspect.createLogger(JestAspect.id);
|
|
22
|
-
const jestWorker = await worker.declareWorker<JestWorker>(WORKER_NAME, require.resolve('./jest.worker'));
|
|
23
|
-
return new JestMain(jestWorker, logger);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
JestAspect.addRuntime(JestMain);
|
package/jest.tester.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs-extra';
|
|
2
|
-
import minimatch from 'minimatch';
|
|
3
|
-
import { compact, flatten } from 'lodash';
|
|
4
|
-
import { proxy } from 'comlink';
|
|
5
|
-
import { Logger } from '@teambit/logger';
|
|
6
|
-
import { HarmonyWorker } from '@teambit/worker';
|
|
7
|
-
import { Tester, CallbackFn, TesterContext, Tests, ComponentPatternsMap } from '@teambit/tester';
|
|
8
|
-
import { TestsFiles, TestResult, TestsResult } from '@teambit/tests-results';
|
|
9
|
-
import { TestResult as JestTestResult, AggregatedResult } from '@jest/test-result';
|
|
10
|
-
import { formatResultsErrors } from 'jest-message-util';
|
|
11
|
-
import { ComponentMap, ComponentID } from '@teambit/component';
|
|
12
|
-
import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
13
|
-
import type jest from 'jest';
|
|
14
|
-
import { JestError } from './error';
|
|
15
|
-
import type { JestWorker } from './jest.worker';
|
|
16
|
-
|
|
17
|
-
export class JestTester implements Tester {
|
|
18
|
-
private readonly jestModule: typeof jest;
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
readonly id: string,
|
|
22
|
-
readonly jestConfig: any,
|
|
23
|
-
private jestModulePath: string,
|
|
24
|
-
private jestWorker: HarmonyWorker<JestWorker>,
|
|
25
|
-
private logger: Logger
|
|
26
|
-
) {
|
|
27
|
-
// eslint-disable-next-line global-require,import/no-dynamic-require
|
|
28
|
-
this.jestModule = require(jestModulePath);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
configPath = this.jestConfig;
|
|
32
|
-
|
|
33
|
-
displayName = 'Jest';
|
|
34
|
-
|
|
35
|
-
_callback: CallbackFn | undefined;
|
|
36
|
-
|
|
37
|
-
displayConfig() {
|
|
38
|
-
return readFileSync(this.jestConfig, 'utf8');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
version() {
|
|
42
|
-
return this.jestModule.getVersion();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// private getTestFile(path: string, testerContext: TesterContext): AbstractVinyl | undefined {
|
|
46
|
-
// return testerContext.specFiles.toArray().reduce((acc: AbstractVinyl | undefined, [, specs]) => {
|
|
47
|
-
// const file = specs.find((spec) => spec.path === path);
|
|
48
|
-
// if (file) acc = file;
|
|
49
|
-
// return acc;
|
|
50
|
-
// }, undefined);
|
|
51
|
-
// }
|
|
52
|
-
|
|
53
|
-
private attachTestsToComponent(testerContext: TesterContext, testResult: JestTestResult[]) {
|
|
54
|
-
return ComponentMap.as(testerContext.components, (component) => {
|
|
55
|
-
const componentSpecFiles = testerContext.patterns.get(component);
|
|
56
|
-
if (!componentSpecFiles) return undefined;
|
|
57
|
-
const [, specs] = componentSpecFiles;
|
|
58
|
-
return testResult.filter((test) => {
|
|
59
|
-
return specs.filter((pattern) => minimatch(test.testFilePath, pattern.path)).length > 0;
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private buildTestsObj(
|
|
65
|
-
aggregatedResult: AggregatedResult,
|
|
66
|
-
components: ComponentMap<JestTestResult[] | undefined>,
|
|
67
|
-
testerContext: TesterContext,
|
|
68
|
-
config?: any
|
|
69
|
-
) {
|
|
70
|
-
const testsSuiteResult = components.toArray().map(([component, testsFiles]) => {
|
|
71
|
-
if (!testsFiles) return;
|
|
72
|
-
if (testsFiles?.length === 0) return;
|
|
73
|
-
const tests = testsFiles.map((test) => {
|
|
74
|
-
const file = new AbstractVinyl({ path: test.testFilePath, contents: readFileSync(test.testFilePath) });
|
|
75
|
-
const testResults = test.testResults.map((testResult) => {
|
|
76
|
-
const error = formatResultsErrors([testResult], config, { noStackTrace: true }) || undefined;
|
|
77
|
-
const isFailure = testResult.status === 'failed';
|
|
78
|
-
return new TestResult(
|
|
79
|
-
testResult.ancestorTitles,
|
|
80
|
-
testResult.title,
|
|
81
|
-
testResult.status,
|
|
82
|
-
testResult.duration,
|
|
83
|
-
isFailure ? undefined : error,
|
|
84
|
-
isFailure ? error : undefined
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
const filePath = file?.basename || test.testFilePath;
|
|
88
|
-
const error = {
|
|
89
|
-
failureMessage: test.testExecError ? test.failureMessage : undefined,
|
|
90
|
-
error: test.testExecError?.message,
|
|
91
|
-
};
|
|
92
|
-
return new TestsFiles(
|
|
93
|
-
filePath,
|
|
94
|
-
testResults,
|
|
95
|
-
test.numPassingTests,
|
|
96
|
-
test.numFailingTests,
|
|
97
|
-
test.numPendingTests,
|
|
98
|
-
test.perfStats.runtime,
|
|
99
|
-
test.perfStats.slow,
|
|
100
|
-
error
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
// TODO @guy - fix this eslint error
|
|
104
|
-
// eslint-disable-next-line
|
|
105
|
-
return {
|
|
106
|
-
componentId: component.id,
|
|
107
|
-
results: new TestsResult(tests, aggregatedResult.success, aggregatedResult.startTime),
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return compact(testsSuiteResult) as { componentId: ComponentID; results: TestsResult }[];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private getErrors(testResult: JestTestResult[]): JestError[] {
|
|
115
|
-
return testResult.reduce((errors: JestError[], test) => {
|
|
116
|
-
if (test.testExecError) {
|
|
117
|
-
const { message, stack, code, type } = test.testExecError;
|
|
118
|
-
errors.push(new JestError(message, stack, code, type));
|
|
119
|
-
}
|
|
120
|
-
if (test.failureMessage) {
|
|
121
|
-
errors.push(new JestError(test.failureMessage));
|
|
122
|
-
}
|
|
123
|
-
return errors;
|
|
124
|
-
}, []);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async onTestRunComplete(callback: CallbackFn) {
|
|
128
|
-
this._callback = callback;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async test(context: TesterContext): Promise<Tests> {
|
|
132
|
-
const config: any = {
|
|
133
|
-
rootDir: context.rootPath,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// eslint-disable-next-line no-console
|
|
137
|
-
console.warn = (message: string) => {
|
|
138
|
-
this.logger.warn(message);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
if (context.debug) config.runInBand = true;
|
|
142
|
-
if (context.coverage) config.coverage = true;
|
|
143
|
-
config.runInBand = true;
|
|
144
|
-
|
|
145
|
-
if (context.watch) {
|
|
146
|
-
config.watchAll = true;
|
|
147
|
-
config.noCache = true;
|
|
148
|
-
}
|
|
149
|
-
// eslint-disable-next-line global-require,import/no-dynamic-require
|
|
150
|
-
const jestConfig = require(this.jestConfig);
|
|
151
|
-
|
|
152
|
-
const jestConfigWithSpecs = Object.assign(jestConfig, {
|
|
153
|
-
testMatch: this.patternsToArray(context.patterns),
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const withEnv = Object.assign(jestConfigWithSpecs, config);
|
|
157
|
-
const testsOutPut = await this.jestModule.runCLI(withEnv, [this.jestConfig]);
|
|
158
|
-
const testResults = testsOutPut.results.testResults;
|
|
159
|
-
const componentsWithTests = this.attachTestsToComponent(context, testResults);
|
|
160
|
-
const componentTestResults = this.buildTestsObj(
|
|
161
|
-
testsOutPut.results,
|
|
162
|
-
componentsWithTests,
|
|
163
|
-
context,
|
|
164
|
-
jestConfigWithSpecs
|
|
165
|
-
);
|
|
166
|
-
const globalErrors = this.getErrors(testResults);
|
|
167
|
-
return { components: componentTestResults, errors: globalErrors };
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
async watch(context: TesterContext): Promise<Tests> {
|
|
171
|
-
// eslint-disable-next-line
|
|
172
|
-
return new Promise(async (resolve) => {
|
|
173
|
-
const workerApi = this.jestWorker.initiate(
|
|
174
|
-
context.ui ? { stdout: true, stderr: true, stdin: true } : { stdout: false, stderr: false, stdin: false }
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
// eslint-disable-next-line
|
|
178
|
-
const jestConfig = require(this.jestConfig);
|
|
179
|
-
|
|
180
|
-
const jestConfigWithSpecs = Object.assign(jestConfig, {
|
|
181
|
-
testMatch: this.patternsToArray(context.patterns),
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
const cbFn = proxy((results) => {
|
|
186
|
-
if (!this._callback) return;
|
|
187
|
-
const testResults = results.testResults;
|
|
188
|
-
const componentsWithTests = this.attachTestsToComponent(context, testResults);
|
|
189
|
-
const componentTestResults = this.buildTestsObj(results, componentsWithTests, context, jestConfigWithSpecs);
|
|
190
|
-
const globalErrors = this.getErrors(testResults);
|
|
191
|
-
const watchTestResults = {
|
|
192
|
-
loading: false,
|
|
193
|
-
errors: globalErrors,
|
|
194
|
-
components: componentTestResults,
|
|
195
|
-
};
|
|
196
|
-
this._callback(watchTestResults);
|
|
197
|
-
resolve(watchTestResults);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
201
|
-
await workerApi.onTestComplete(cbFn);
|
|
202
|
-
|
|
203
|
-
await workerApi.watch(
|
|
204
|
-
this.jestConfig,
|
|
205
|
-
this.patternsToArray(context.patterns),
|
|
206
|
-
context.rootPath,
|
|
207
|
-
this.jestModulePath
|
|
208
|
-
);
|
|
209
|
-
} catch (err: any) {
|
|
210
|
-
this.logger.error('jest.tester.watch() caught an error', err);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private patternsToArray(patterns: ComponentPatternsMap) {
|
|
216
|
-
return flatten(patterns.toArray().map(([, pattern]) => pattern.map((p) => p.path)));
|
|
217
|
-
}
|
|
218
|
-
}
|
package/jest.worker.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { stringify, parse } from 'flatted';
|
|
2
|
-
import { expose } from '@teambit/worker';
|
|
3
|
-
import type jest from 'jest';
|
|
4
|
-
|
|
5
|
-
export class JestWorker {
|
|
6
|
-
private onTestCompleteCb;
|
|
7
|
-
|
|
8
|
-
onTestComplete(onTestComplete) {
|
|
9
|
-
this.onTestCompleteCb = onTestComplete;
|
|
10
|
-
// return this;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
watch(jestConfigPath: string, testFiles: string[], rootPath: string, jestModulePath: string): Promise<void> {
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
// TODO: remove this after jest publish new version to npm: https://github.com/facebook/jest/pull/10804
|
|
16
|
-
// eslint-disable-next-line
|
|
17
|
-
console.warn = function () {};
|
|
18
|
-
// eslint-disable-next-line import/no-dynamic-require,global-require
|
|
19
|
-
const jestConfig = require(jestConfigPath);
|
|
20
|
-
// eslint-disable-next-line import/no-dynamic-require,global-require
|
|
21
|
-
const jestModule: typeof jest = require(jestModulePath);
|
|
22
|
-
|
|
23
|
-
const jestConfigWithSpecs = Object.assign(jestConfig, {
|
|
24
|
-
testMatch: testFiles,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const config: any = {
|
|
28
|
-
// useStderr: true,
|
|
29
|
-
// TODO: check way to enable it
|
|
30
|
-
runInBand: true,
|
|
31
|
-
silent: false,
|
|
32
|
-
rootDir: rootPath,
|
|
33
|
-
watch: true,
|
|
34
|
-
watchAll: true,
|
|
35
|
-
watchPlugins: [
|
|
36
|
-
[
|
|
37
|
-
`${__dirname}/watch.js`,
|
|
38
|
-
{
|
|
39
|
-
specFiles: testFiles,
|
|
40
|
-
onComplete: (results) => {
|
|
41
|
-
if (!this.onTestCompleteCb) return;
|
|
42
|
-
try {
|
|
43
|
-
const json = parse(stringify(results));
|
|
44
|
-
this.onTestCompleteCb(json);
|
|
45
|
-
// disable eslint because we want to catch error but not print it on worker
|
|
46
|
-
// eslint-disable-next-line
|
|
47
|
-
} catch (error: any) {}
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
],
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const withEnv = Object.assign(jestConfigWithSpecs, config);
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
56
|
-
const res = jestModule.runCLI(withEnv, [jestConfigPath]);
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
res.catch((err) => console.error(err));
|
|
59
|
-
resolve();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
expose(new JestWorker());
|
|
Binary file
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|
package/watch.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Prompt, WatchPlugin, JestHookSubscriber, UsageData } from 'jest-watcher';
|
|
2
|
-
import { SpecFiles } from '@teambit/tester';
|
|
3
|
-
|
|
4
|
-
export type PluginConfig = {
|
|
5
|
-
onComplete: (testSuite: any) => void;
|
|
6
|
-
specFiles: SpecFiles;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
class Watch implements WatchPlugin {
|
|
10
|
-
_stdin: NodeJS.ReadStream;
|
|
11
|
-
|
|
12
|
-
_stdout: NodeJS.WriteStream;
|
|
13
|
-
|
|
14
|
-
_prompt: Prompt;
|
|
15
|
-
|
|
16
|
-
_testResults: any;
|
|
17
|
-
|
|
18
|
-
_usageInfo: UsageData;
|
|
19
|
-
|
|
20
|
-
_specFiles: SpecFiles;
|
|
21
|
-
|
|
22
|
-
_onComplete: (testSuite: any) => void;
|
|
23
|
-
|
|
24
|
-
constructor({
|
|
25
|
-
stdin,
|
|
26
|
-
stdout,
|
|
27
|
-
config,
|
|
28
|
-
}: {
|
|
29
|
-
stdin: NodeJS.ReadStream;
|
|
30
|
-
stdout: NodeJS.WriteStream;
|
|
31
|
-
config: PluginConfig;
|
|
32
|
-
}) {
|
|
33
|
-
this._stdin = stdin;
|
|
34
|
-
this._stdout = stdout;
|
|
35
|
-
this._specFiles = config.specFiles;
|
|
36
|
-
this._onComplete = config.onComplete;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private findComponent(specFile: string) {
|
|
40
|
-
const component = this._specFiles.toArray().find(([, specs]) => {
|
|
41
|
-
const paths = specs.map((spec) => spec.path);
|
|
42
|
-
if (paths.includes(specFile)) return true;
|
|
43
|
-
return false;
|
|
44
|
-
});
|
|
45
|
-
return component?.[0];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
apply(jestHooks: JestHookSubscriber) {
|
|
49
|
-
// jestHooks.shouldRunTestSuite(async (testSuite) => {
|
|
50
|
-
// const component = this.findComponent(testSuite.testPath);
|
|
51
|
-
// if ((await component?.isModified()) || (await component?.isNew())) return true;
|
|
52
|
-
// return false;
|
|
53
|
-
// });
|
|
54
|
-
|
|
55
|
-
jestHooks.onTestRunComplete((results) => {
|
|
56
|
-
this._onComplete(results);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
module.exports = Watch;
|