@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/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": [
4
- "es2019",
5
- "DOM",
6
- "ES6",
7
- "DOM.Iterable",
8
- "ScriptHost"
9
- ],
10
- "target": "es2015",
11
- "module": "commonjs",
12
- "jsx": "react",
13
- "declaration": true,
14
- "sourceMap": true,
15
- "skipLibCheck": true,
16
- "moduleResolution": "node",
17
- "esModuleInterop": true,
18
- "outDir": "dist",
19
- "composite": true,
20
- "emitDeclarationOnly": true,
21
- "experimentalDecorators": true,
22
- "emitDecoratorMetadata": true,
23
- "allowSyntheticDefaultImports": true,
24
- "strictPropertyInitialization": false,
25
- "strict": true,
26
- "noImplicitAny": false,
27
- "rootDir": ".",
28
- "removeComments": true,
29
- "preserveConstEnums": true,
30
- "resolveJsonModule": true
31
- },
32
- "exclude": [
33
- "dist"
34
- ]
35
- }
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
- }
@@ -1,20 +0,0 @@
1
- .testsPage {
2
- padding: 50px 40px 100px 40px;
3
- width: 100%;
4
- overflow-y: auto;
5
- max-width: 1440px;
6
- margin: 0 auto;
7
- box-sizing: border-box;
8
-
9
- .title {
10
- margin-bottom: 24px;
11
- font-size: var(--bit-h-xs, 26px);
12
- }
13
- .separator {
14
- margin-bottom: 41px;
15
- }
16
- }
17
-
18
- .testBlock {
19
- margin-bottom: 50px;
20
- }
package/ui/tests-page.tsx DELETED
@@ -1,134 +0,0 @@
1
- import { useQuery, useSubscription, gql } from '@apollo/client';
2
- import { ComponentContext } from '@teambit/component';
3
- import { H1 } from '@teambit/documenter.ui.heading';
4
- import { Separator } from '@teambit/design.ui.separator';
5
- import { EmptyBox } from '@teambit/design.ui.empty-box';
6
- import { MDXLayout } from '@teambit/mdx.ui.mdx-layout';
7
- import { AlertCard } from '@teambit/design.ui.alert-card';
8
- import { TestLoader } from '@teambit/defender.ui.test-loader';
9
- import classNames from 'classnames';
10
- import React, { HTMLAttributes, useContext } from 'react';
11
- import { TestTable } from '@teambit/defender.ui.test-table';
12
- import { EmptyStateSlot } from '../tester.ui.runtime';
13
- import styles from './tests-page.module.scss';
14
-
15
- const TESTS_SUBSCRIPTION_CHANGED = gql`
16
- subscription OnTestsChanged($id: String!) {
17
- testsChanged(id: $id) {
18
- testsResults {
19
- testFiles {
20
- file
21
- duration
22
- pass
23
- failed
24
- pending
25
- error {
26
- failureMessage
27
- }
28
- tests {
29
- ancestor
30
- duration
31
- status
32
- name
33
- error
34
- }
35
- }
36
- }
37
- }
38
- }
39
- `;
40
-
41
- const GET_COMPONENT = gql`
42
- query($id: String!) {
43
- getHost {
44
- id # for GQL caching
45
- getTests(id: $id) {
46
- loading
47
- testsResults {
48
- testFiles {
49
- file
50
- duration
51
- pass
52
- failed
53
- pending
54
- error {
55
- failureMessage
56
- }
57
- tests {
58
- ancestor
59
- duration
60
- status
61
- name
62
- error
63
- }
64
- }
65
- }
66
- }
67
- }
68
- }
69
- `;
70
-
71
- type TestsPageProps = {
72
- emptyState: EmptyStateSlot;
73
- } & HTMLAttributes<HTMLDivElement>;
74
-
75
- export function TestsPage({ className, emptyState }: TestsPageProps) {
76
- const component = useContext(ComponentContext);
77
- const onTestsChanged = useSubscription(TESTS_SUBSCRIPTION_CHANGED, { variables: { id: component.id.toString() } });
78
- const { data } = useQuery(GET_COMPONENT, {
79
- variables: { id: component.id._legacy.name },
80
- });
81
-
82
- const testData = onTestsChanged.data?.testsChanged || data?.getHost?.getTests;
83
- const testResults = testData?.testsResults?.testFiles;
84
-
85
- // TODO: change loading EmptyBox
86
- if (testData?.loading) return <TestLoader />;
87
-
88
- const env = component.environment?.id;
89
- const EmptyStateTemplate = emptyState.get(env || '');
90
-
91
- if (
92
- (testResults === null || testData?.testsResults === null) &&
93
- component.host === 'teambit.workspace/workspace' &&
94
- EmptyStateTemplate
95
- ) {
96
- return (
97
- <div className={classNames(styles.testsPage, className)}>
98
- <div>
99
- <H1 className={styles.title}>Tests</H1>
100
- <Separator isPresentational className={styles.separator} />
101
- <AlertCard
102
- level="info"
103
- title="There are no
104
- tests for this Component. Learn how to add tests:"
105
- >
106
- <MDXLayout>
107
- <EmptyStateTemplate />
108
- </MDXLayout>
109
- </AlertCard>
110
- </div>
111
- </div>
112
- );
113
- }
114
-
115
- if (testResults === null || testData?.testsResults === null) {
116
- return (
117
- <EmptyBox
118
- title="This component doesn’t have any tests."
119
- linkText="Learn how to add tests to your components"
120
- link="https://harmony-docs.bit.dev/testing/overview/"
121
- />
122
- );
123
- }
124
-
125
- return (
126
- <div className={classNames(styles.testsPage, className)}>
127
- <div>
128
- <H1 className={styles.title}>Tests</H1>
129
- <Separator isPresentational className={styles.separator} />
130
- <TestTable testResults={testResults} className={styles.testBlock} />
131
- </div>
132
- </div>
133
- );
134
- }
@@ -1,12 +0,0 @@
1
- import { Component } from '@teambit/component';
2
- import { DevFilesMain } from '@teambit/dev-files';
3
- import { TesterAspect } from '../tester.aspect';
4
-
5
- /**
6
- * detect test files in components
7
- */
8
- export function detectTestFiles(component: Component, devFiles: DevFilesMain) {
9
- const files = devFiles.getDevFiles(component);
10
- const testFiles = files.get(TesterAspect.id);
11
- return component.state.filesystem.files.filter((file) => testFiles.includes(file.relative));
12
- }
package/utils/index.ts DELETED
@@ -1 +0,0 @@
1
- export { detectTestFiles } from './detect-spec-files';
@@ -1,35 +0,0 @@
1
- import junitReportBuilder from 'junit-report-builder';
2
- import stripAnsi from 'strip-ansi';
3
- import { ComponentsResults } from '../tester';
4
-
5
- export function testsResultsToJUnitFormat(components: ComponentsResults[]): string {
6
- const builder = junitReportBuilder.newBuilder();
7
- components.forEach((compResult) => {
8
- const suite = builder.testSuite().name(compResult.componentId.toString());
9
- if (compResult.results?.start) {
10
- suite.timestamp(new Date(compResult.results?.start).toISOString());
11
- }
12
- compResult.results?.testFiles.forEach((testFile) => {
13
- if (testFile.error?.error) {
14
- const testCase = suite.testCase().className(testFile.file).name(testFile.file);
15
- testCase.error(stripAnsi(testFile.error.error as string));
16
- }
17
- testFile.tests.forEach((test) => {
18
- const testCase = suite.testCase().className(testFile.file).name(test.name);
19
- if (test.error) {
20
- testCase.error(stripAnsi(test.error));
21
- }
22
- if (test.failure) {
23
- testCase.failure(stripAnsi(test.failure));
24
- }
25
- if (test.status === 'skipped' || test.status === 'pending') {
26
- testCase.skipped();
27
- }
28
- if (test.duration) {
29
- testCase.time(test.duration / 1000);
30
- }
31
- });
32
- });
33
- });
34
- return builder.build();
35
- }