Skip to content

Commit 4b5bc2e

Browse files
test: add integration test
- Test action execution with spawnSync - Configure GitHub Actions runner environment variables - Verify action completes successfully (exit code 0) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
1 parent db353a9 commit 4b5bc2e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/index.integration.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { spawnSync } from 'node:child_process';
2+
import { resolve } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
import { describe, expect, it } from 'vitest';
6+
7+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
8+
const nodePath = process.execPath;
9+
const actionPath = resolve(__dirname, '../dist/index.js');
10+
const tmpPath = resolve(__dirname, '../node_modules/.tmp');
11+
12+
describe('integration', () => {
13+
it('runs action', () => {
14+
const env = {
15+
'INPUT_CLI-NAME': 'gh',
16+
'INPUT_CLI-VERSION': '2.27.0',
17+
RUNNER_TOOL_CACHE: resolve(tmpPath, 'runner_tool_cache'),
18+
RUNNER_TEMP: resolve(tmpPath, 'runner_temp'),
19+
};
20+
21+
const result = spawnSync(nodePath, [actionPath], {
22+
env,
23+
stdio: 'ignore', // 'inherit' to stream output in real-time
24+
});
25+
26+
expect(result.status).toBe(0);
27+
});
28+
});

0 commit comments

Comments
 (0)