Skip to content

Commit

Permalink
Migrate to vitest (#108)
Browse files Browse the repository at this point in the history
* Migrate to `vitest` runner
* Port the rest of template tests
* Update CI workflows
* Bail out after first failing test
* Run server.test in both dev and prod mode
  • Loading branch information
szymmis authored Jan 21, 2024
1 parent 1dd4603 commit 15506fc
Show file tree
Hide file tree
Showing 27 changed files with 1,373 additions and 697 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- cli-v*
jobs:
test:
name: Run tests on npm build
name: Run tests on local build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
node-version: 20
- run: yarn install
- run: yarn test:local
- run: yarn test
publish:
name: Publish package
runs-on: ubuntu-latest
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
name: Test the package
on: pull_request
jobs:
test-npm:
name: Run tests on npm build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: yarn install
- run: yarn test
test-local:
name: Run tests on local build
runs-on: ubuntu-latest
Expand All @@ -20,4 +10,4 @@ jobs:
with:
node-version: 20
- run: yarn install
- run: yarn test:local
- run: yarn test
8 changes: 1 addition & 7 deletions create-vite-express/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import * as kolorist from "kolorist";
import path from "path";
import prompts from "prompts";

type Template = prompts.Choice & { color: (msg: string) => string };

const TEMPLATES: Template[] = [
{ title: "Vanilla", value: "vanilla", color: kolorist.yellow },
{ title: "React", value: "react", color: kolorist.cyan },
{ title: "Vue", value: "vue", color: kolorist.green },
];
import { TEMPLATES } from "./templates";

async function main() {
const answers = await prompts([
Expand Down
10 changes: 10 additions & 0 deletions create-vite-express/src/templates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as kolorist from "kolorist";
import prompts from "prompts";

type Template = prompts.Choice & { color: (msg: string) => string };

export const TEMPLATES: Template[] = [
{ title: "Vanilla", value: "vanilla", color: kolorist.yellow },
{ title: "React", value: "react", color: kolorist.cyan },
{ title: "Vue", value: "vue", color: kolorist.green },
];
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
test:
image: node:20-slim
command: yarn test
working_dir: /app
volumes:
- .:/app
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"dev": "concurrently -i -P \"sh scripts/dev.sh {1}\" \"yarn build --watch\" --",
"build": "rollup --config rollup.config.js --bundleConfigAsCjs",
"postbuild": "sed -i \"s/export default _default/export = _default/\" dist/main.d.ts",
"test": "tsx tests/index.test.ts",
"test:local": "LOCAL_BUILD_TEST=true tsx tests/index.test.ts",
"pretest": "yarn build",
"test": "vitest --pool=forks",
"format": "prettier --write --loglevel silent",
"lint": "eslint --fix",
"type-check": "tsc --noEmit; tsc --noEmit -p create-vite-express/tsconfig.json",
Expand Down Expand Up @@ -52,7 +52,8 @@
"tslib": "^2.6.2",
"tsx": "^4.5.0",
"typescript": "^5.3.2",
"vite": "^5.0.2"
"vite": "^5.0.2",
"vitest": "^1.1.1"
},
"files": [
"./dist"
Expand Down
40 changes: 0 additions & 40 deletions tests/cli.test.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions tests/index.test.ts

This file was deleted.

134 changes: 0 additions & 134 deletions tests/lib/runner.ts

This file was deleted.

106 changes: 0 additions & 106 deletions tests/lib/utils.ts

This file was deleted.

Loading

0 comments on commit 15506fc

Please sign in to comment.