tests: fix hanging tests locally (#408)

Also add a test for --vscode for the init script.
This commit is contained in:
Luca Casonato
2022-07-04 15:16:49 +00:00
committed by GitHub
parent aab8ceb78b
commit e0e669ef3d
+27 -11
View File
@@ -14,16 +14,10 @@ type FileTree = {
type: "directory";
name: string;
contents: FileTree[];
} | {
type: "report";
directories: number;
files: number;
};
const assertFileExistence = async (tree: FileTree[], dirname?: string) => {
for (const t of tree) {
if (t.type === "report") continue;
const stat = await Deno.stat(
dirname ? [dirname, t.name].join("/") : t.name,
);
@@ -47,7 +41,15 @@ Deno.test({
await t.step("execute init command", async () => {
const cliProcess = Deno.run({
cmd: ["deno", "run", "-A", "init.ts", tmpDirName, "--no-twind"],
cmd: [
"deno",
"run",
"-A",
"init.ts",
tmpDirName,
"--no-twind",
"--no-vscode",
],
stdout: "null",
});
const { code } = await cliProcess.status();
@@ -96,7 +98,6 @@ Deno.test({
},
],
},
{ "type": "report", "directories": 3, "files": 8 },
];
await t.step("check generated files", async () => {
@@ -160,14 +161,22 @@ Deno.test({
});
Deno.test({
name: "fresh-init --twind",
name: "fresh-init --twind --vscode",
async fn(t) {
// Preparation
const tmpDirName = await Deno.makeTempDir();
await t.step("execute init command", async () => {
const cliProcess = Deno.run({
cmd: ["deno", "run", "-A", "init.ts", tmpDirName, "--twind"],
cmd: [
"deno",
"run",
"-A",
"init.ts",
tmpDirName,
"--twind",
"--vscode",
],
stdout: "null",
});
const { code } = await cliProcess.status();
@@ -221,9 +230,16 @@ Deno.test({
{ "type": "file", "name": "twind.ts" },
],
},
{
"type": "directory",
"name": ".vscode",
"contents": [
{ "type": "file", "name": "settings.json" },
{ "type": "file", "name": "extensions.json" },
],
},
],
},
{ "type": "report", "directories": 4, "files": 9 },
];
await t.step("check generated files", async () => {