kunkun/apps/create-kunkun/__tests__/create-template.test.ts
Huakun Shen ad30a8c3bb
fix: duplicate api calls from comlink (#27)
* refactor: replace comlink with kkrpc

* fix: import path in api pkg and btn styling in ui iframe page

* fix: fixed fetch API from kkRPC migrate

* refactor: replace comlink-stdio with kkrpc

* update deno lock

* bump @kksh/api

* update API version

* publish api pkg again to fix kkrpc version

* update pnpm lock

* dep: fix dependency problems

* dep: update deno.lock

* chore: remove 2 submodules

they were added only for integration development

* update pnpm lock

* fix: test template path

* format: with prettier

* downgrade next version

* ci: try to fix next build on windows

* try to fix CI

* Revert "try to fix CI"

This reverts commit b9c63c392f50f1d2d3ceec406e49b1af2348c740.

* upgrade tauri-api-adapter

* try to fix next

* remove templates from pnpm workspace

* update CI test

* publish @kksh/api with upgraded tauri-api-adapter to fix nextjs template
2024-11-19 05:57:31 -05:00

43 lines
1.7 KiB
TypeScript

/**
* This is a E2E test, create every template from production build and run `npm install` and `npm run build`
* When running `npm install` with bun shell, it fails in bun test environment, so I simply run everything as regular ts without test()
*/
import os from "os"
import path from "path"
import { $ } from "bun"
import { afterAll, beforeAll, describe, expect, test } from "bun:test"
import fs from "fs-extra"
import { getRootDir } from "../src/constants"
const testDir = path.join(os.tmpdir(), "kunkun-create-kunkun-test")
console.log("Test Dir: ", testDir)
const distDir = path.join(getRootDir(), "dist")
const indexjsPath = path.join(distDir, "index.mjs")
const templateNames = ["template", "react", "vue", "nuxt", "svelte", "sveltekit"]
fs.rmdirSync(testDir, { recursive: true })
fs.mkdirpSync(testDir)
await Promise.all(
templateNames.map(async (templateName) => {
const folderName = `${templateName}-ext`
await $`node ${indexjsPath} --outdir ${testDir} --name ${folderName} --template ${templateName}`
const templateDir = path.join(testDir, folderName)
await $`rm -rf node_modules`.cwd(templateDir).text() // this doesn't work within bun test
await $`pnpm install`.cwd(templateDir).text() // this doesn't work within bun test
await $`pnpm run build`.cwd(templateDir).text()
})
)
test("Build Artifact Existence", () => {
templateNames.forEach(async (templateName) => {
const expectedOutDir = templateName === "sveltekit" ? "build" : "dist"
const folderName = `${templateName}-ext`
const templateDir = path.join(testDir, folderName)
expect(fs.existsSync(path.join(templateDir, expectedOutDir))).toBeTrue()
})
})
afterAll(() => {
fs.rmdirSync(testDir, { recursive: true })
})