Skip to content

Commit 9ffc138

Browse files
committed
fix test
1 parent 18dd37c commit 9ffc138

File tree

4 files changed

+67
-16
lines changed

4 files changed

+67
-16
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* AUTO-GENERATED - DO NOT EDIT */
2+
export declare const bodyAttributes: {
3+
"data-child": "closed" | "open";
4+
"data-faq": "closed" | "open";
5+
"data-mobile": "false" | "true";
6+
"data-number": "1" | "2";
7+
"data-scope": "off" | "on";
8+
"data-theme": "dark" | "light";
9+
"data-theme-2": "dark" | "light";
10+
"data-theme-three": "dark" | "light";
11+
"data-toggle-boolean": "false" | "true";
12+
"data-toggle-function": "black" | "blue" | "green" | "red" | "white";
13+
"data-use-effect-theme": "dark" | "light";
14+
};
15+
16+
export declare const variantKeyMap: {
17+
[key: string]: true;
18+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* AUTO-GENERATED - DO NOT EDIT */
2+
export const bodyAttributes = {
3+
"data-child": "closed",
4+
"data-number": "1",
5+
"data-theme": "light",
6+
"data-theme-2": "light",
7+
"data-theme-three": "light",
8+
"data-toggle-boolean": "true",
9+
"data-toggle-function": "white",
10+
"data-use-effect-theme": "light"
11+
};
12+
export const variantKeyMap = {
13+
"data-child": true,
14+
"data-faq": true,
15+
"data-mobile": true,
16+
"data-number": true,
17+
"data-scope": true,
18+
"data-theme": true,
19+
"data-theme-2": true,
20+
"data-theme-three": true,
21+
"data-toggle-boolean": true,
22+
"data-toggle-function": true,
23+
"data-use-effect-theme": true
24+
};
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import zeroUI from "@react-zero-ui/core/vite";
12
import { defineConfig } from 'vite';
23
import react from '@vitejs/plugin-react';
34

45
// https://vite.dev/config/
56
export default defineConfig({
6-
plugins: [react()],
7+
plugins: [zeroUI(), react()]
78
});

packages/core/__tests__/helpers/loadCli.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
// __tests__/helpers/loadCli.js
2-
import { createRequire } from 'node:module';
2+
import { dirname } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { execSync } from 'node:child_process';
35
import path from 'node:path';
46

57
export async function loadCliFromFixture(fixtureDir) {
6-
const r = createRequire(path.join(fixtureDir, 'package.json'));
7-
const modulePath = r.resolve('../../../dist/cli/init.js'); // get the path
8-
const mod = r(modulePath); // actually require the module
9-
console.log('[Global Setup] Loaded CLI from fixture:', modulePath);
10-
// Return a wrapper function that changes directory before running CLI
11-
const wrappedCli = async (args = []) => {
8+
// Get the directory of this helper file
9+
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
console.log('__dirname: ', __dirname);
11+
12+
// Build the path to the CLI module - from helpers/ go up to core/ then to dist/
13+
const modulePath = path.resolve(__dirname, '../../dist/cli/init.js');
14+
console.log('[Global Setup] CLI path:', modulePath);
15+
16+
// Return a wrapper function that runs CLI as separate process to avoid module loading issues
17+
const wrappedCli = async () => {
1218
const originalCwd = process.cwd();
1319
try {
1420
process.chdir(fixtureDir); // Change to fixture directory
21+
console.log('[Global Setup] Changed to fixture directory:', fixtureDir);
1522

16-
// The init.js exports a cli function, so call it
23+
// Run the CLI as a separate Node.js process to avoid module loading conflicts
24+
const result = execSync(`node "${modulePath}"`, { stdio: 'pipe', encoding: 'utf-8', timeout: 30000 });
1725

18-
if (typeof mod === 'function') {
19-
return await Promise.resolve(mod(args)); // run the CLI
20-
} else if (typeof mod.default === 'function') {
21-
return await Promise.resolve(mod.default(args)); // run the CLI (ESM default export)
22-
} else {
23-
throw new Error('Could not find CLI function in init.js');
24-
}
26+
console.log('[Global Setup] CLI executed successfully');
27+
return result;
28+
} catch (error) {
29+
console.error('[Global Setup] CLI execution failed:', error.message);
30+
if (error.stdout) console.log('STDOUT:', error.stdout);
31+
if (error.stderr) console.log('STDERR:', error.stderr);
32+
throw error;
2533
} finally {
2634
process.chdir(originalCwd); // Always restore original directory
2735
console.log('[Global Setup] Restored original directory:', originalCwd);

0 commit comments

Comments
 (0)