-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from watonyweng/feat/integrate/vitest
feat(cli): support vitest test
- Loading branch information
Showing
4 changed files
with
797 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,4 @@ jobs: | |
cache: pnpm | ||
- run: pnpm install --frozen-lockfile | ||
- run: pnpm build | ||
- run: pnpm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { join } from 'node:path' | ||
import type { ExecaSyncReturnValue, SyncOptions } from 'execa' | ||
import { execaCommandSync } from 'execa' | ||
import fs from 'fs-extra' | ||
import { afterEach, beforeAll, expect, test } from 'vitest' | ||
|
||
const CLI_PATH = join(__dirname, '..') | ||
|
||
const projectName = 'electron-vite-app' | ||
const generatePath = join(__dirname, projectName) | ||
|
||
const run = ( | ||
args: string[], | ||
options: SyncOptions = {}, | ||
): ExecaSyncReturnValue => { | ||
return execaCommandSync(`node ${CLI_PATH} ${args.join(' ')}`, options) | ||
} | ||
|
||
const createNonEmptyDir = () => { | ||
// Create the temporary directory | ||
fs.mkdirpSync(generatePath) | ||
|
||
// Create a package.json file | ||
const pkgJson = join(generatePath, 'package.json') | ||
fs.writeFileSync(pkgJson, '{ "foo": "bar" }') | ||
} | ||
|
||
beforeAll(() => fs.remove(generatePath)) | ||
afterEach(() => fs.remove(generatePath)) | ||
|
||
test('prompts for the project name if none supplied', () => { | ||
const { stdout } = run([]) | ||
expect(stdout).toContain('Project name:') | ||
}) | ||
|
||
test('prompts for project template if none supplied when target dir is current directory', () => { | ||
fs.mkdirpSync(generatePath) | ||
const { stdout } = run(['.'], { cwd: generatePath }) | ||
expect(stdout).toContain('Project template:') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.