@teambit/tester 0.0.551 → 0.0.556
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/tester.d.ts +64 -0
- package/dist/tester.main.runtime.d.ts +72 -1
- package/dist/tester.service.d.ts +20 -1
- package/dist/tester.task.d.ts +3 -0
- package/dist/tester.ui.runtime.d.ts +3 -0
- package/dist/utils/detect-spec-files.d.ts +3 -0
- package/package.json +25 -19
- package/exceptions/index.ts +0 -2
- package/exceptions/no-matching-components.ts +0 -5
- package/exceptions/no-test-files-found.ts +0 -7
- package/index.ts +0 -8
- package/package-tar/teambit-tester-0.0.551.tgz +0 -0
- package/test.cmd.tsx +0 -93
- package/tester.aspect.ts +0 -7
- package/tester.graphql.ts +0 -83
- package/tester.main.runtime.ts +0 -245
- package/tester.service.tsx +0 -161
- package/tester.task.ts +0 -111
- package/tester.ts +0 -126
- package/tester.ui.runtime.tsx +0 -42
- package/tests.section.tsx +0 -18
- package/tsconfig.json +0 -35
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/ui/tests-page.module.scss +0 -20
- package/ui/tests-page.tsx +0 -134
- package/utils/detect-spec-files.ts +0 -12
- package/utils/index.ts +0 -1
- package/utils/junit-generator.ts +0 -35
package/dist/tester.d.ts
CHANGED
|
@@ -17,26 +17,90 @@ export declare type ComponentPatternsMap = ComponentMap<{
|
|
|
17
17
|
relative: string;
|
|
18
18
|
}[]>;
|
|
19
19
|
export interface TesterContext extends ExecutionContext {
|
|
20
|
+
/**
|
|
21
|
+
* whether the tester run for release (during bit build/tag) or not (during bit test command).
|
|
22
|
+
*/
|
|
20
23
|
release: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* list of components to test.
|
|
26
|
+
*/
|
|
21
27
|
components: Component[];
|
|
28
|
+
/**
|
|
29
|
+
* component workspace.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* defines whether tester is expected to run in quiet mode.
|
|
33
|
+
*/
|
|
22
34
|
quiet?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* list of spec files to test.
|
|
37
|
+
*/
|
|
23
38
|
specFiles: SpecFiles;
|
|
39
|
+
/**
|
|
40
|
+
* rootPath of the component workspace or the capsule root dir (during build).
|
|
41
|
+
*/
|
|
24
42
|
rootPath: string;
|
|
43
|
+
/**
|
|
44
|
+
* determines whether tester is expected to run in debug mode.
|
|
45
|
+
*/
|
|
25
46
|
debug?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* is start from ui
|
|
49
|
+
*/
|
|
26
50
|
ui?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* determines whether to start the tester in watch mode.
|
|
53
|
+
*/
|
|
27
54
|
watch?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* whether the tester should show code coverage
|
|
57
|
+
*/
|
|
28
58
|
coverage?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* array of patterns to test.
|
|
61
|
+
*/
|
|
29
62
|
patterns: ComponentPatternsMap;
|
|
30
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* tester interface allows extensions to implement a component tester into bit.
|
|
66
|
+
*/
|
|
31
67
|
export interface Tester {
|
|
68
|
+
/**
|
|
69
|
+
* display name of the tester.
|
|
70
|
+
*/
|
|
32
71
|
displayName?: string;
|
|
72
|
+
/**
|
|
73
|
+
* icon of the tester.
|
|
74
|
+
*/
|
|
33
75
|
icon?: string;
|
|
76
|
+
/**
|
|
77
|
+
* serialized config of the tester.
|
|
78
|
+
*/
|
|
34
79
|
displayConfig?(): string;
|
|
80
|
+
/**
|
|
81
|
+
* path to the config in the filesystem.
|
|
82
|
+
*/
|
|
35
83
|
configPath?: string;
|
|
84
|
+
/**
|
|
85
|
+
* id of the tester.
|
|
86
|
+
*/
|
|
36
87
|
id: string;
|
|
88
|
+
/**
|
|
89
|
+
* on test run complete. (applies only during watch)
|
|
90
|
+
* @param callback
|
|
91
|
+
*/
|
|
37
92
|
onTestRunComplete?(callback: CallbackFn): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* execute tests on all components in the given execution context.
|
|
95
|
+
*/
|
|
38
96
|
test(context: TesterContext): Promise<Tests>;
|
|
97
|
+
/**
|
|
98
|
+
* watch tests on all components
|
|
99
|
+
*/
|
|
39
100
|
watch?(context: TesterContext): Promise<Tests>;
|
|
101
|
+
/**
|
|
102
|
+
* return the tester version.
|
|
103
|
+
*/
|
|
40
104
|
version(): string;
|
|
41
105
|
}
|
|
42
106
|
export declare type CallbackFn = (testSuite: Tests) => void;
|
|
@@ -12,35 +12,97 @@ import { ComponentsResults, CallbackFn, Tests } from './tester';
|
|
|
12
12
|
import { TesterService } from './tester.service';
|
|
13
13
|
import { TesterTask } from './tester.task';
|
|
14
14
|
export declare type TesterExtensionConfig = {
|
|
15
|
+
/**
|
|
16
|
+
* regex of the text environment.
|
|
17
|
+
*/
|
|
15
18
|
testRegex: string;
|
|
19
|
+
/**
|
|
20
|
+
* determine whether to watch on start.
|
|
21
|
+
*/
|
|
16
22
|
watchOnStart: boolean;
|
|
17
23
|
patterns: string[];
|
|
18
24
|
};
|
|
19
25
|
export declare type TesterOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* start the tester in watch mode.
|
|
28
|
+
*/
|
|
20
29
|
watch: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* start the tester in debug mode.
|
|
32
|
+
*/
|
|
21
33
|
debug: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* start the tester in debug mode.
|
|
36
|
+
*/
|
|
22
37
|
ui?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* initiate the tester on given env.
|
|
40
|
+
*/
|
|
23
41
|
env?: string;
|
|
42
|
+
/**
|
|
43
|
+
* generate JUnit files on the specified dir
|
|
44
|
+
*/
|
|
24
45
|
junit?: string;
|
|
46
|
+
/**
|
|
47
|
+
* show code coverage
|
|
48
|
+
*/
|
|
25
49
|
coverage?: boolean;
|
|
26
50
|
callback?: CallbackFn;
|
|
27
51
|
};
|
|
28
52
|
export declare class TesterMain {
|
|
53
|
+
/**
|
|
54
|
+
* graphql extension.
|
|
55
|
+
*/
|
|
29
56
|
private graphql;
|
|
57
|
+
/**
|
|
58
|
+
* envs extension.
|
|
59
|
+
*/
|
|
30
60
|
private envs;
|
|
61
|
+
/**
|
|
62
|
+
* workspace extension.
|
|
63
|
+
*/
|
|
31
64
|
private workspace;
|
|
65
|
+
/**
|
|
66
|
+
* tester service.
|
|
67
|
+
*/
|
|
32
68
|
readonly service: TesterService;
|
|
69
|
+
/**
|
|
70
|
+
* build task.
|
|
71
|
+
*/
|
|
33
72
|
readonly task: TesterTask;
|
|
34
73
|
private devFiles;
|
|
35
74
|
private builder;
|
|
36
75
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
37
76
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
38
|
-
constructor(
|
|
77
|
+
constructor(
|
|
78
|
+
/**
|
|
79
|
+
* graphql extension.
|
|
80
|
+
*/
|
|
81
|
+
graphql: GraphqlMain,
|
|
82
|
+
/**
|
|
83
|
+
* envs extension.
|
|
84
|
+
*/
|
|
85
|
+
envs: EnvsMain,
|
|
86
|
+
/**
|
|
87
|
+
* workspace extension.
|
|
88
|
+
*/
|
|
89
|
+
workspace: Workspace,
|
|
90
|
+
/**
|
|
91
|
+
* tester service.
|
|
92
|
+
*/
|
|
93
|
+
service: TesterService,
|
|
94
|
+
/**
|
|
95
|
+
* build task.
|
|
96
|
+
*/
|
|
97
|
+
task: TesterTask, devFiles: DevFilesMain, builder: BuilderMain);
|
|
39
98
|
_testsResults: {
|
|
40
99
|
[componentId: string]: ComponentsResults;
|
|
41
100
|
} | undefined[];
|
|
42
101
|
test(components: Component[], opts?: TesterOptions): Promise<EnvsExecutionResult<Tests>>;
|
|
43
102
|
private generateJUnit;
|
|
103
|
+
/**
|
|
104
|
+
* watch all components for changes and test upon each.
|
|
105
|
+
*/
|
|
44
106
|
watch(components: Component[], opts?: TesterOptions): Promise<EnvsExecutionResult<Tests>>;
|
|
45
107
|
uiWatch(): Promise<EnvsExecutionResult<Tests>>;
|
|
46
108
|
getTestsResults(component: Component): Promise<{
|
|
@@ -48,10 +110,19 @@ export declare class TesterMain {
|
|
|
48
110
|
loading: boolean;
|
|
49
111
|
} | undefined>;
|
|
50
112
|
private getTestsResultsFromState;
|
|
113
|
+
/**
|
|
114
|
+
* get all test files of a component.
|
|
115
|
+
*/
|
|
51
116
|
getTestFiles(component: Component): import("@teambit/legacy/dist/consumer/component/sources").AbstractVinyl[];
|
|
52
117
|
private getOptions;
|
|
53
118
|
static defaultConfig: {
|
|
119
|
+
/**
|
|
120
|
+
* default test regex for which files tester to apply on.
|
|
121
|
+
*/
|
|
54
122
|
patterns: string[];
|
|
123
|
+
/**
|
|
124
|
+
* determine whether to watch on start.
|
|
125
|
+
*/
|
|
55
126
|
watchOnStart: boolean;
|
|
56
127
|
};
|
|
57
128
|
static provider([cli, envs, workspace, loggerAspect, graphql, ui, devFiles, builder]: [
|
package/dist/tester.service.d.ts
CHANGED
|
@@ -7,20 +7,39 @@ import { Tests, CallbackFn } from './tester';
|
|
|
7
7
|
import { TesterOptions } from './tester.main.runtime';
|
|
8
8
|
export declare const OnTestsChanged = "OnTestsChanged";
|
|
9
9
|
export declare type TesterDescriptor = {
|
|
10
|
+
/**
|
|
11
|
+
* id of the tester (e.g. jest/mocha)
|
|
12
|
+
*/
|
|
10
13
|
id: string;
|
|
14
|
+
/**
|
|
15
|
+
* display name of the tester (e.g. Jest / Mocha)
|
|
16
|
+
*/
|
|
11
17
|
displayName: string;
|
|
18
|
+
/**
|
|
19
|
+
* icon of the configured tester.
|
|
20
|
+
*/
|
|
12
21
|
icon: string;
|
|
22
|
+
/**
|
|
23
|
+
* string containing the config for display.
|
|
24
|
+
*/
|
|
13
25
|
config: string;
|
|
14
26
|
version?: string;
|
|
15
27
|
};
|
|
16
28
|
export declare class TesterService implements EnvService<Tests, TesterDescriptor> {
|
|
17
29
|
readonly workspace: Workspace;
|
|
30
|
+
/**
|
|
31
|
+
* regex used to identify which files to test.
|
|
32
|
+
*/
|
|
18
33
|
readonly patterns: string[];
|
|
19
34
|
private logger;
|
|
20
35
|
private pubsub;
|
|
21
36
|
private devFiles;
|
|
22
37
|
name: string;
|
|
23
|
-
constructor(workspace: Workspace,
|
|
38
|
+
constructor(workspace: Workspace,
|
|
39
|
+
/**
|
|
40
|
+
* regex used to identify which files to test.
|
|
41
|
+
*/
|
|
42
|
+
patterns: string[], logger: Logger, pubsub: PubSub, devFiles: DevFilesMain);
|
|
24
43
|
_callback: CallbackFn | undefined;
|
|
25
44
|
render(env: EnvDefinition): JSX.Element;
|
|
26
45
|
getDescriptor(environment: EnvDefinition): {
|
package/dist/tester.task.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BuildContext, BuiltTaskResult, BuildTask } from '@teambit/builder';
|
|
2
2
|
import { DevFilesMain } from '@teambit/dev-files';
|
|
3
|
+
/**
|
|
4
|
+
* tester build task. Allows to test components during component build.
|
|
5
|
+
*/
|
|
3
6
|
export declare class TesterTask implements BuildTask {
|
|
4
7
|
readonly aspectId: string;
|
|
5
8
|
private devFiles;
|
|
@@ -9,6 +9,9 @@ export declare class TesterUI {
|
|
|
9
9
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
10
10
|
stageKey?: string;
|
|
11
11
|
constructor(component: ComponentUI, emptyStateSlot: EmptyStateSlot);
|
|
12
|
+
/**
|
|
13
|
+
* register a new tester empty state. this allows to register a different empty state from each environment for example.
|
|
14
|
+
*/
|
|
12
15
|
registerEmptyState(emptyStateComponent: ComponentType): this;
|
|
13
16
|
static slots: ((registerFn: () => string) => SlotRegistry<ComponentType<{}>>)[];
|
|
14
17
|
static provider([component]: [ComponentUI], config: any, [emptyStateSlot]: [EmptyStateSlot]): Promise<TesterUI>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Component } from '@teambit/component';
|
|
2
2
|
import { DevFilesMain } from '@teambit/dev-files';
|
|
3
|
+
/**
|
|
4
|
+
* detect test files in components
|
|
5
|
+
*/
|
|
3
6
|
export declare function detectTestFiles(component: Component, devFiles: DevFilesMain): import("@teambit/legacy/dist/consumer/component/sources").AbstractVinyl[];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/tester",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.556",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/defender/tester",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.defender",
|
|
8
8
|
"name": "tester",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.556"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"@babel/runtime": "7.12.18",
|
|
25
25
|
"core-js": "^3.0.0",
|
|
26
26
|
"@teambit/documenter.ui.heading": "4.1.1",
|
|
27
|
-
"@teambit/cli": "0.0.
|
|
28
|
-
"@teambit/logger": "0.0.
|
|
29
|
-
"@teambit/workspace": "0.0.
|
|
30
|
-
"@teambit/component": "0.0.
|
|
31
|
-
"@teambit/graphql": "0.0.
|
|
32
|
-
"@teambit/builder": "0.0.
|
|
33
|
-
"@teambit/dev-files": "0.0.
|
|
34
|
-
"@teambit/envs": "0.0.
|
|
35
|
-
"@teambit/tests-results": "0.0.
|
|
36
|
-
"@teambit/ui": "0.0.
|
|
37
|
-
"@teambit/compiler": "0.0.
|
|
38
|
-
"@teambit/bit-error": "0.0.
|
|
39
|
-
"@teambit/defender.ui.test-loader": "0.0.
|
|
40
|
-
"@teambit/defender.ui.test-table": "0.0.
|
|
27
|
+
"@teambit/cli": "0.0.387",
|
|
28
|
+
"@teambit/logger": "0.0.472",
|
|
29
|
+
"@teambit/workspace": "0.0.556",
|
|
30
|
+
"@teambit/component": "0.0.556",
|
|
31
|
+
"@teambit/graphql": "0.0.556",
|
|
32
|
+
"@teambit/builder": "0.0.556",
|
|
33
|
+
"@teambit/dev-files": "0.0.556",
|
|
34
|
+
"@teambit/envs": "0.0.556",
|
|
35
|
+
"@teambit/tests-results": "0.0.73",
|
|
36
|
+
"@teambit/ui": "0.0.556",
|
|
37
|
+
"@teambit/compiler": "0.0.556",
|
|
38
|
+
"@teambit/bit-error": "0.0.373",
|
|
39
|
+
"@teambit/defender.ui.test-loader": "0.0.466",
|
|
40
|
+
"@teambit/defender.ui.test-table": "0.0.469",
|
|
41
41
|
"@teambit/design.ui.alert-card": "0.0.13",
|
|
42
42
|
"@teambit/design.ui.empty-box": "0.0.352",
|
|
43
43
|
"@teambit/design.ui.separator": "0.0.351",
|
|
44
|
-
"@teambit/mdx.ui.mdx-layout": "0.0.
|
|
44
|
+
"@teambit/mdx.ui.mdx-layout": "0.0.468"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/react": "^17.0.8",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@apollo/client": "^3.0.0",
|
|
60
|
-
"@teambit/legacy": "1.0.
|
|
60
|
+
"@teambit/legacy": "1.0.173",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
62
62
|
"react": "^16.8.0 || ^17.0.0"
|
|
63
63
|
},
|
|
@@ -85,12 +85,18 @@
|
|
|
85
85
|
"react": "-"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@teambit/legacy": "1.0.
|
|
88
|
+
"@teambit/legacy": "1.0.173",
|
|
89
89
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
90
90
|
"react": "^16.8.0 || ^17.0.0"
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
+
"files": [
|
|
95
|
+
"dist",
|
|
96
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
97
|
+
"README.md",
|
|
98
|
+
"README.mdx"
|
|
99
|
+
],
|
|
94
100
|
"private": false,
|
|
95
101
|
"engines": {
|
|
96
102
|
"node": ">=12.22.0"
|
package/exceptions/index.ts
DELETED
package/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TesterAspect } from './tester.aspect';
|
|
2
|
-
|
|
3
|
-
export type { Tester, Tests, TesterContext, CallbackFn, SpecFiles, ComponentPatternsMap } from './tester';
|
|
4
|
-
export type { TesterMain } from './tester.main.runtime';
|
|
5
|
-
export type { TesterUI } from './tester.ui.runtime';
|
|
6
|
-
|
|
7
|
-
export { TesterAspect };
|
|
8
|
-
export default TesterAspect;
|
|
Binary file
|
package/test.cmd.tsx
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { Logger } from '@teambit/logger';
|
|
4
|
-
import { Workspace } from '@teambit/workspace';
|
|
5
|
-
import { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';
|
|
6
|
-
import { Timer } from '@teambit/legacy/dist/toolbox/timer';
|
|
7
|
-
import { Box, Text } from 'ink';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { NoMatchingComponents } from './exceptions';
|
|
10
|
-
|
|
11
|
-
import type { TesterMain } from './tester.main.runtime';
|
|
12
|
-
|
|
13
|
-
type TestFlags = {
|
|
14
|
-
watch: boolean;
|
|
15
|
-
debug: boolean;
|
|
16
|
-
env?: string;
|
|
17
|
-
scope?: string;
|
|
18
|
-
junit?: string;
|
|
19
|
-
coverage?: boolean;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export class TestCmd implements Command {
|
|
23
|
-
name = 'test [pattern]';
|
|
24
|
-
description = 'test set of components in your workspace';
|
|
25
|
-
alias = 'at';
|
|
26
|
-
group = 'development';
|
|
27
|
-
shortDescription = '';
|
|
28
|
-
options = [
|
|
29
|
-
['w', 'watch', 'start the tester in watch mode.'],
|
|
30
|
-
['d', 'debug', 'start the tester in debug mode.'],
|
|
31
|
-
['', 'junit <filepath>', 'write tests results as JUnit XML format into the specified file path'],
|
|
32
|
-
['', 'coverage', 'show code coverage data'],
|
|
33
|
-
['e', 'env <id>', 'test only the given env'],
|
|
34
|
-
['s', 'scope <scope>', 'name of the scope to test'],
|
|
35
|
-
// TODO: we need to reduce this redundant casting every time.
|
|
36
|
-
] as CommandOptions;
|
|
37
|
-
|
|
38
|
-
constructor(private tester: TesterMain, private workspace: Workspace, private logger: Logger) {}
|
|
39
|
-
|
|
40
|
-
async render(
|
|
41
|
-
[userPattern]: [string],
|
|
42
|
-
{ watch = false, debug = false, env, scope, junit, coverage = false }: TestFlags
|
|
43
|
-
) {
|
|
44
|
-
this.logger.off();
|
|
45
|
-
const timer = Timer.create();
|
|
46
|
-
const scopeName = typeof scope === 'string' ? scope : undefined;
|
|
47
|
-
timer.start();
|
|
48
|
-
if (!this.workspace) throw new ConsumerNotFound();
|
|
49
|
-
const pattern = userPattern && userPattern.toString();
|
|
50
|
-
const components =
|
|
51
|
-
pattern || scopeName ? await this.workspace.byPattern(pattern || '*', scopeName) : await this.workspace.list();
|
|
52
|
-
|
|
53
|
-
if (!components.length) throw new NoMatchingComponents(pattern);
|
|
54
|
-
|
|
55
|
-
this.logger.console(
|
|
56
|
-
`testing total of ${components.length} components in workspace '${chalk.cyan(this.workspace.name)}'`
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
let code = 0;
|
|
60
|
-
if (watch && !debug) {
|
|
61
|
-
await this.tester.watch(components, {
|
|
62
|
-
watch,
|
|
63
|
-
debug,
|
|
64
|
-
env,
|
|
65
|
-
coverage,
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
const tests = await this.tester.test(components, {
|
|
69
|
-
watch,
|
|
70
|
-
debug,
|
|
71
|
-
env,
|
|
72
|
-
junit,
|
|
73
|
-
coverage,
|
|
74
|
-
});
|
|
75
|
-
tests?.results?.forEach((test) => (test.data?.errors?.length ? (code = 1) : null));
|
|
76
|
-
}
|
|
77
|
-
const { seconds } = timer.stop();
|
|
78
|
-
|
|
79
|
-
if (watch) return <Box></Box>;
|
|
80
|
-
return {
|
|
81
|
-
code,
|
|
82
|
-
data: (
|
|
83
|
-
<Box>
|
|
84
|
-
<Text>tested </Text>
|
|
85
|
-
<Text color="cyan">{components.length} </Text>
|
|
86
|
-
<Text>components in </Text>
|
|
87
|
-
<Text color="cyan">{seconds} </Text>
|
|
88
|
-
<Text>seconds.</Text>
|
|
89
|
-
</Box>
|
|
90
|
-
),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
package/tester.aspect.ts
DELETED
package/tester.graphql.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { GraphqlMain, Schema } from '@teambit/graphql';
|
|
2
|
-
import { ComponentFactory } from '@teambit/component';
|
|
3
|
-
import { withFilter } from 'graphql-subscriptions';
|
|
4
|
-
import gql from 'graphql-tag';
|
|
5
|
-
|
|
6
|
-
import { TesterMain } from './tester.main.runtime';
|
|
7
|
-
import { OnTestsChanged } from './tester.service';
|
|
8
|
-
|
|
9
|
-
export function testerSchema(tester: TesterMain, graphql: GraphqlMain): Schema {
|
|
10
|
-
return {
|
|
11
|
-
typeDefs: gql`
|
|
12
|
-
extend type ComponentHost {
|
|
13
|
-
getTests(id: String!): Tests
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type Subscription {
|
|
17
|
-
testsChanged(id: String!): Tests
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type Tests {
|
|
21
|
-
loading: Boolean!
|
|
22
|
-
testsResults: TestsResults
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type TestsChanged {
|
|
26
|
-
testsResults: TestsResults
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type TestsResults {
|
|
30
|
-
testFiles: [TestFiles]
|
|
31
|
-
success: Boolean
|
|
32
|
-
start: Int
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type TestFiles {
|
|
36
|
-
file: String
|
|
37
|
-
tests: [Tests]
|
|
38
|
-
pass: Int
|
|
39
|
-
failed: Int
|
|
40
|
-
pending: Int
|
|
41
|
-
duration: Int
|
|
42
|
-
slow: Boolean
|
|
43
|
-
error: TestError
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type TestError {
|
|
47
|
-
failureMessage: String
|
|
48
|
-
error: String
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type Tests {
|
|
52
|
-
ancestor: [String]
|
|
53
|
-
name: String
|
|
54
|
-
duration: String
|
|
55
|
-
status: String
|
|
56
|
-
error: String
|
|
57
|
-
}
|
|
58
|
-
`,
|
|
59
|
-
resolvers: {
|
|
60
|
-
Subscription: {
|
|
61
|
-
testsChanged: {
|
|
62
|
-
subscribe: withFilter(
|
|
63
|
-
() => graphql.pubsub.asyncIterator(OnTestsChanged),
|
|
64
|
-
(payload, variables) => {
|
|
65
|
-
return payload.testsChanged.id === variables.id;
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
ComponentHost: {
|
|
72
|
-
getTests: async (host: ComponentFactory, { id }: { id: string }) => {
|
|
73
|
-
const componentId = await host.resolveComponentId(id);
|
|
74
|
-
const component = await host.get(componentId);
|
|
75
|
-
if (!component) return null;
|
|
76
|
-
const testsResults = await tester.getTestsResults(component);
|
|
77
|
-
if (!testsResults) return null;
|
|
78
|
-
return testsResults;
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|