-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsmoke.test.js
More file actions
29 lines (25 loc) · 1.19 KB
/
smoke.test.js
File metadata and controls
29 lines (25 loc) · 1.19 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';
// Basic smoke test: run the CLI with a temp directory and ensure it creates expected folders.
describe('create-polyglot CLI smoke', () => {
const tmpParent = fs.mkdtempSync(path.join(os.tmpdir(), 'polyglot-smoke-'));
let tmpDir = path.join(tmpParent, 'workspace');
fs.mkdirSync(tmpDir);
const projName = 'smoke-proj';
afterAll(() => {
// Cleanup temp directory
try { fs.rmSync(tmpParent, { recursive: true, force: true }); } catch {}
});
it('scaffolds a project with a node service (using init subcommand)', async () => {
const repoRoot = process.cwd();
const cliPath = path.join(repoRoot, 'bin/index.js');
await execa('node', [cliPath, 'init', projName, '--services', 'node', '--no-install', '--yes'], { cwd: tmpDir });
const projectPath = path.join(tmpDir, projName);
expect(fs.existsSync(path.join(projectPath, 'services/node'))).toBe(true);
expect(fs.existsSync(path.join(projectPath, 'package.json'))).toBe(true);
expect(fs.existsSync(path.join(projectPath, 'polyglot.json'))).toBe(true);
}, 30000);
});