Skip to content

Commit 8f3e6af

Browse files
committed
chore: Moves mock generation to the scripts
1 parent 0296e08 commit 8f3e6af

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"homepage": "https://cloudscape.design",
1111
"scripts": {
1212
"lint": "eslint --ignore-path .gitignore --ext js,ts .",
13-
"build": "tsc -b && node scripts/generate-package.js && node scripts/generate-doc.js && node scripts/generate-exports.js",
13+
"build": "tsc -b && node scripts/generate-package.js && node scripts/generate-doc.js && node scripts/generate-exports.js && node scripts/build-mocks.js",
1414
"postbuild": "cp NOTICE README.md LICENSE lib/core && cp NOTICE README.md LICENSE lib/converter",
1515
"test": "vitest run",
1616
"posttest": "node ./scripts/verify-typescript.js",

scripts/build-mocks.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
const path = require('path');
4+
const { generateTestUtils } = require('../lib/converter/dist/generate-test-utils');
5+
6+
const mockComponents = [
7+
{
8+
name: 'TestComponentA',
9+
pluralName: 'TestComponentAs',
10+
},
11+
{
12+
name: 'TestComponentB',
13+
pluralName: 'TestComponentBs',
14+
},
15+
];
16+
17+
const testUtilsPath = path.resolve(__dirname, '../src/converter/test/mock-test-utils');
18+
generateTestUtils({
19+
components: mockComponents,
20+
testUtilsPath,
21+
});

src/converter/test/generate-test-utils-snapshot.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('index files', () => {
99

1010
test.each(testUtilTypes)('%s index file matches the snapshot', testUtilType => {
1111
const testUtilsIndexFilePath = path.resolve(__dirname, `./mock-test-utils/${testUtilType}/index.ts`);
12-
const content = fs.readFileSync(testUtilsIndexFilePath);
12+
const content = fs.readFileSync(testUtilsIndexFilePath, { encoding: 'utf8' });
1313
expect(content).toMatchSnapshot();
1414
});
1515
});

vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export default defineConfig({
1212
include: ['src/**'],
1313
exclude: ['**/debug-tools/**', '**/test/**'],
1414
},
15-
setupFiles: [path.resolve(__dirname, './src/converter/setup-tests.ts')],
1615
},
1716
resolve: {
1817
alias: {

0 commit comments

Comments
 (0)