Skip to content

Commit 7c00c25

Browse files
committed
preview new test-utils
1 parent 42a9704 commit 7c00c25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1543
-27
lines changed

build-tools/tasks/docs.js

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
const path = require('path');
4-
const { writeComponentsDocumentation, documentTestUtils } = require('@cloudscape-design/documenter');
5-
const { writeFile } = require('../utils/files');
4+
const { writeComponentsDocumentation, writeTestUtilsDocumentation } = require('../../test-utils-new');
65
const workspace = require('../utils/workspace');
76

87
module.exports = function docs() {
@@ -15,27 +14,17 @@ module.exports = function docs() {
1514
TagEditor: ['getTagsDiff'],
1615
},
1716
});
18-
testUtilDocs();
17+
writeTestUtilsDocumentation({
18+
outDir: path.join(workspace.apiDocsPath, 'test-utils-doc'),
19+
tsconfigPath: require.resolve('../../src/test-utils/tsconfig.json'),
20+
domUtils: {
21+
root: 'src/test-utils/dom/index.ts',
22+
extraExports: ['default', 'ElementWrapper'],
23+
},
24+
selectorsUtils: {
25+
root: 'src/test-utils/selectors/index.ts',
26+
extraExports: ['default', 'ElementWrapper'],
27+
},
28+
});
1929
return Promise.resolve();
2030
};
21-
22-
function testUtilDocs() {
23-
['dom', 'selectors'].forEach(testUtilType => {
24-
const baseWrapperDefinitions = require(`@cloudscape-design/test-utils-core/test-utils-doc/${testUtilType}`);
25-
const componentWrapperDefinitions = documentTestUtils(
26-
{
27-
tsconfig: require.resolve('../../src/test-utils/tsconfig.json'),
28-
},
29-
`**/{${testUtilType},types}/**/*`
30-
);
31-
32-
const definitions = [...baseWrapperDefinitions.classes, ...componentWrapperDefinitions];
33-
const indexContent = `module.exports = {
34-
classes: ${JSON.stringify(definitions)}
35-
}
36-
`;
37-
38-
const outPath = path.join(workspace.apiDocsPath, 'test-utils-doc', `${testUtilType}.js`);
39-
writeFile(outPath, indexContent);
40-
});
41-
}

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default tsEslint.config(
2525
includeIgnoreFile(path.resolve('.gitignore')),
2626
{
2727
// this code does not run, only used as a text content
28-
ignores: ['pages/code-editor/samples/**'],
28+
ignores: ['pages/code-editor/samples/**', 'test-utils-new'],
2929
},
3030
{
3131
settings: {

src/__tests__/snapshot-tests/documenter.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import definitions from '../../../lib/components-definitions/components';
4-
// @ts-expect-error no typings
54
import testUtilDomDefinitions from '../../../lib/components-definitions/test-utils-doc/dom';
6-
// @ts-expect-error no typings
75
import testUtilSelectorsDefinitions from '../../../lib/components-definitions/test-utils-doc/selectors';
86
import { getAllComponents } from '../utils';
97

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { TypeDocAndTSOptions, ProjectReflection } from 'typedoc';
2+
export declare function bootstrapProject(options: Partial<TypeDocAndTSOptions>, filteringGlob?: string, additionalInputFilePaths?: string[]): ProjectReflection;

test-utils-new/bootstrap/index.js

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-utils-new/bootstrap/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import ts from 'typescript';
2+
export declare function bootstrapTypescriptProject(tsconfigPath: string): ts.Program;

test-utils-new/bootstrap/typescript.js

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-utils-new/bootstrap/typescript.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import ts from 'typescript';
2+
import type { ComponentDefinition } from './interfaces';
3+
import type { ExpandedProp, ExtractedDescription } from './extractor';
4+
export declare function buildComponentDefinition(name: string, dashCaseName: string, props: Array<ExpandedProp>, functions: Array<ExpandedProp>, defaultValues: Record<string, string>, componentDescription: ExtractedDescription, checker: ts.TypeChecker): ComponentDefinition;

0 commit comments

Comments
 (0)