File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed
Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change 11// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22
3- exports [` definition for ' code-view' matches the snapshot 1` ] = `
3+ exports [` definition for code-view matches the snapshot > code-view 1` ] = `
44{
55 " dashCaseName" : " code-view" ,
66 " events" : [],
Original file line number Diff line number Diff line change 22// SPDX-License-Identifier: Apache-2.0
33import { expect , test } from "vitest" ;
44
5- import apiDocs from "../../lib/components/internal/api-docs/components" ;
5+ import componentDefinitions from "../../lib/components/internal/api-docs/components" ;
6+ import { getAllComponents } from "./utils" ;
67
7- test . each ( Object . entries ( apiDocs ) ) ( "definition for $0 matches the snapshot" , ( _name , definition ) => {
8- expect ( definition ) . toMatchSnapshot ( ) ;
8+ test . each < string > ( getAllComponents ( ) ) ( `definition for %s matches the snapshot` , ( componentName : string ) => {
9+ const definition = componentDefinitions [ componentName ] ;
10+ // overriding with a fake value so that when there are icon changes in components this test doesn't block it
11+ const iconNameDefinition = definition . properties . find ( ( { name } : { name : string } ) => name === "iconName" ) ;
12+ if ( iconNameDefinition && iconNameDefinition . inlineType ?. type === "union" ) {
13+ iconNameDefinition . inlineType . values = [ "comes from @cloudscape-design/components" ] ;
14+ }
15+ expect ( definition ) . toMatchSnapshot ( componentName ) ;
916} ) ;
Original file line number Diff line number Diff line change 1+ /* eslint-env node */
2+ /* eslint-disable header/header */
3+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+ // SPDX-License-Identifier: Apache-2.0
5+ import * as fs from "node:fs" ;
6+ import * as path from "node:path" ;
7+
8+ const componentsDir = path . resolve ( __dirname , "../../lib/components" ) ;
9+
10+ export function getAllComponents ( ) : string [ ] {
11+ return fs
12+ . readdirSync ( componentsDir )
13+ . filter (
14+ ( name ) =>
15+ name !== "internal" &&
16+ name !== "test-utils" &&
17+ ! name . includes ( "." ) &&
18+ ! name . includes ( "LICENSE" ) &&
19+ ! name . includes ( "NOTICE" ) ,
20+ ) ;
21+ }
22+
23+ export async function requireComponent ( componentName : string ) {
24+ // eslint-disable-next-line no-unsanitized/method
25+ const { default : Component } = await import ( path . join ( componentsDir , componentName ) ) ;
26+ return Component ;
27+ }
You can’t perform that action at this time.
0 commit comments