@teambit/tester 1.0.106 → 1.0.108

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/tester.ts ADDED
@@ -0,0 +1,172 @@
1
+ import { Component, ComponentID, ComponentMap } from '@teambit/component';
2
+ import { ExecutionContext } from '@teambit/envs';
3
+ import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
4
+ import { TestsResult } from '@teambit/tests-results';
5
+
6
+ export class Tests {
7
+ constructor(public components: ComponentsResults[]) {}
8
+ get errors(): Error[] {
9
+ return this.components.map((comp) => comp.errors || []).flat();
10
+ }
11
+ }
12
+
13
+ export type ComponentsResults = {
14
+ /**
15
+ * component id.
16
+ */
17
+ componentId: ComponentID;
18
+ /**
19
+ * test results for the component.
20
+ */
21
+ results?: TestsResult;
22
+ /**
23
+ * aggregated errors from all files
24
+ */
25
+ errors?: Error[];
26
+
27
+ /**
28
+ * loading.
29
+ */
30
+ loading?: boolean;
31
+ };
32
+
33
+ export type SpecFiles = ComponentMap<AbstractVinyl[]>;
34
+
35
+ export type ComponentPatternsEntry = {
36
+ /**
37
+ * component directory in the workspace.
38
+ */
39
+ componentDir: string;
40
+
41
+ /**
42
+ * paths to test files.
43
+ */
44
+ paths: { path: string; relative: string }[];
45
+
46
+ /**
47
+ * root dir of the package in bit_roots.
48
+ */
49
+ packageRootDir: string;
50
+ };
51
+
52
+ export type ComponentPatternsMap = ComponentMap<ComponentPatternsEntry>;
53
+
54
+ export interface TesterContext extends ExecutionContext {
55
+ /**
56
+ * whether the tester run for release (during bit build/tag) or not (during bit test command).
57
+ */
58
+ release: boolean;
59
+
60
+ /**
61
+ * list of components to test.
62
+ */
63
+ components: Component[];
64
+
65
+ /**
66
+ * component workspace.
67
+ */
68
+ // workspace: Workspace;
69
+
70
+ /**
71
+ * defines whether tester is expected to run in quiet mode.
72
+ */
73
+ quiet?: boolean;
74
+
75
+ /**
76
+ * list of spec files to test.
77
+ */
78
+ specFiles: SpecFiles;
79
+
80
+ /**
81
+ * rootPath of the component workspace or the capsule root dir (during build).
82
+ */
83
+ rootPath: string;
84
+
85
+ /**
86
+ * determines whether tester is expected to run in debug mode.
87
+ */
88
+ debug?: boolean;
89
+
90
+ /**
91
+ * is start from ui
92
+ */
93
+ ui?: boolean;
94
+
95
+ /**
96
+ * determines whether to start the tester in watch mode.
97
+ */
98
+ watch?: boolean;
99
+
100
+ /**
101
+ * whether the tester should show code coverage
102
+ */
103
+ coverage?: boolean;
104
+
105
+ /**
106
+ * array of patterns to test.
107
+ */
108
+ patterns: ComponentPatternsMap;
109
+
110
+ /**
111
+ *
112
+ * additional test host dependencies
113
+ * This can be used in cases when you want specific dependencies to be resolved from the env during testing
114
+ * but you don't want these dependencies as peer dependencies of the component (as they are not used during runtime)
115
+ * An example for this is @angular/compiler, which during running tests you want to resolve from the env, but you don't
116
+ * need it during component runtime.
117
+ */
118
+ additionalHostDependencies?: string[];
119
+ }
120
+
121
+ /**
122
+ * tester interface allows extensions to implement a component tester into bit.
123
+ */
124
+ export interface Tester {
125
+ /**
126
+ * display name of the tester.
127
+ */
128
+ displayName?: string;
129
+
130
+ /**
131
+ * icon of the tester.
132
+ */
133
+ icon?: string;
134
+
135
+ /**
136
+ * serialized config of the tester.
137
+ */
138
+ displayConfig?(): string;
139
+
140
+ /**
141
+ * path to the config in the filesystem.
142
+ */
143
+ configPath?: string;
144
+
145
+ /**
146
+ * id of the tester.
147
+ */
148
+ id: string;
149
+
150
+ /**
151
+ * on test run complete. (applies only during watch)
152
+ * @param callback
153
+ */
154
+ onTestRunComplete?(callback: CallbackFn): Promise<void>;
155
+
156
+ /**
157
+ * execute tests on all components in the given execution context.
158
+ */
159
+ test(context: TesterContext): Promise<Tests>;
160
+
161
+ /**
162
+ * watch tests on all components
163
+ */
164
+ watch?(context: TesterContext): Promise<Tests>;
165
+
166
+ /**
167
+ * return the tester version.
168
+ */
169
+ version(): string;
170
+ }
171
+
172
+ export type CallbackFn = (testSuite: Tests) => void;
package/tsconfig.json CHANGED
@@ -1,38 +1,33 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
4
+ "esnext",
5
+ "dom",
6
+ "dom.Iterable"
9
7
  ],
10
- "target": "es2015",
11
- "module": "CommonJS",
12
- "jsx": "react",
13
- "allowJs": true,
14
- "composite": true,
8
+ "target": "es2020",
9
+ "module": "es2020",
10
+ "jsx": "react-jsx",
15
11
  "declaration": true,
16
12
  "sourceMap": true,
17
- "skipLibCheck": true,
18
13
  "experimentalDecorators": true,
19
- "outDir": "dist",
14
+ "skipLibCheck": true,
20
15
  "moduleResolution": "node",
21
16
  "esModuleInterop": true,
22
- "rootDir": ".",
23
17
  "resolveJsonModule": true,
24
- "emitDeclarationOnly": true,
25
- "emitDecoratorMetadata": true,
26
- "allowSyntheticDefaultImports": true,
27
- "strictPropertyInitialization": false,
28
- "strict": true,
29
- "noImplicitAny": false,
30
- "preserveConstEnums": true
18
+ "allowJs": true,
19
+ "outDir": "dist",
20
+ "emitDeclarationOnly": true
31
21
  },
32
22
  "exclude": [
23
+ "artifacts",
24
+ "public",
33
25
  "dist",
26
+ "node_modules",
27
+ "package.json",
34
28
  "esm.mjs",
35
- "package.json"
29
+ "**/*.cjs",
30
+ "./dist"
36
31
  ],
37
32
  "include": [
38
33
  "**/*",
package/types/asset.d.ts CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
5
5
  declare module '*.svg' {
6
6
  import type { FunctionComponent, SVGProps } from 'react';
7
7
 
8
- export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
9
11
  const src: string;
10
12
  export default src;
11
13
  }
12
-
13
- // @TODO Gilad
14
14
  declare module '*.jpg' {
15
15
  const value: any;
16
16
  export = value;
@@ -27,3 +27,15 @@ declare module '*.bmp' {
27
27
  const value: any;
28
28
  export = value;
29
29
  }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }