feat(dev): Ignore common test files in routes and islands (#1039)

Co-authored-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
Sebastian Gräßl
2023-09-11 16:05:55 +02:00
committed by GitHub
co-authored by Marvin Hagemeister Asher Gomez
parent 59fff11903
commit e01ef2d8a0
16 changed files with 142 additions and 5 deletions
+5
View File
@@ -32,3 +32,8 @@ export {
export { defineConfig, type Preset } from "https://esm.sh/@twind/core@1.1.3";
export { default as presetTailwind } from "https://esm.sh/@twind/preset-tailwind@1.1.4";
export * as fs from "https://deno.land/std@0.195.0/fs/mod.ts";
export {
dirname,
fromFileUrl,
join,
} from "https://deno.land/std@0.193.0/path/mod.ts";
+51
View File
@@ -0,0 +1,51 @@
import { collect } from "../src/dev/mod.ts";
import { assert, dirname, fromFileUrl, join } from "./deps.ts";
Deno.test({
name: "routes collect",
fn: async () => {
const { routes } = await collect(
join(dirname(fromFileUrl(import.meta.url)), "fixture"),
{},
);
assert(
!routes.includes("routes/not_found.test.ts") &&
!routes.includes("routes\\not_found.test.ts"),
);
assert(
!routes.includes("routes/_404_test.tsx") &&
!routes.includes("routes\\_404_test.tsx"),
);
assert(
!routes.includes("routes/islands/test_test.tsx") &&
!routes.includes("routes\\islands\\test_test.tsx"),
);
},
});
Deno.test({
name: "routes collect with custom pattern",
fn: async () => {
const { routes } = await collect(
join(
dirname(fromFileUrl(import.meta.url)),
"fixture_router_ignore_files",
),
{
router: {
ignoreFilePattern: /[\.|_]cy\.[t|j]s(x)?$/,
},
},
);
assert(
!routes.includes("routes/index.cy.ts") &&
!routes.includes("routes\\index.cy.ts"),
);
assert(
routes.includes("routes/index.tsx") ||
routes.includes("routes\\index.tsx"),
);
},
});
View File
View File
+3
View File
@@ -0,0 +1,3 @@
Deno.test("not really", () => {
return;
});
@@ -0,0 +1,15 @@
{
"lock": false,
"imports": {
"$fresh/": "../../",
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.1",
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.5",
"@preact/signals-core": "https://esm.sh/@preact/signals-core@1.3.1"
},
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
import options from "./options.ts";
await dev(import.meta.url, "./main.ts", options);
@@ -0,0 +1,15 @@
// DO NOT EDIT. This file is generated by Fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import * as $0 from "./routes/index.tsx";
const manifest = {
routes: {
"./routes/index.tsx": $0,
},
islands: {},
baseUrl: import.meta.url,
};
export default manifest;
+11
View File
@@ -0,0 +1,11 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import routes from "./fresh.gen.ts";
import options from "./options.ts";
await start(routes, options);
@@ -0,0 +1,7 @@
import { FreshOptions } from "$fresh/server.ts";
export default {
router: {
ignoreFilePattern: /[\.|_]cy\.[t|j]s(x)?$/,
},
} as FreshOptions;
@@ -0,0 +1,9 @@
import { IS_BROWSER } from "$fresh/runtime.ts";
export default function Home() {
return (
<div>
<p>{IS_BROWSER ? "Viewing browser render." : "Viewing JIT render."}</p>
</div>
);
}