-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathactions-workflow.test.js
More file actions
29 lines (25 loc) · 1.12 KB
/
actions-workflow.test.js
File metadata and controls
29 lines (25 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { execa } from 'execa';
import { describe, it, expect, afterAll } from 'vitest';
import fs from 'fs';
import path from 'path';
import os from 'os';
// Test that --with-actions generates a GitHub Actions workflow file.
describe('GitHub Actions workflow generation', () => {
const tmpParent = fs.mkdtempSync(path.join(os.tmpdir(), 'polyglot-actions-'));
let tmpDir = path.join(tmpParent, 'workspace');
fs.mkdirSync(tmpDir);
const projName = 'ci-proj';
afterAll(() => {
try { fs.rmSync(tmpParent, { recursive: true, force: true }); } catch {}
});
it('creates a ci.yml when --with-actions passed', async () => {
const repoRoot = process.cwd();
const cliPath = path.join(repoRoot, 'bin/index.js');
await execa('node', [cliPath, 'init', projName, '--services', 'node', '--no-install', '--with-actions', '--yes'], { cwd: tmpDir });
const wfPath = path.join(tmpDir, projName, '.github', 'workflows', 'ci.yml');
expect(fs.existsSync(wfPath)).toBe(true);
const content = fs.readFileSync(wfPath, 'utf-8');
expect(content).toMatch(/name: CI/);
expect(content).toMatch(/Run tests/);
}, 30000);
});