Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Jest package setups #11391

Merged
merged 10 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions jest/jest.config.shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = {
"^react-router-dom-v5-compat$":
"<rootDir>/../react-router-dom-v5-compat/index.ts",
"^react-router-native$": "<rootDir>/../react-router-native/index.tsx",
"^@web3-storage/multipart-parser$": require.resolve(
"@web3-storage/multipart-parser"
),
},
modulePathIgnorePatterns: ignorePatterns,
setupFiles: ["<rootDir>/__tests__/setup.ts"],
Expand All @@ -23,9 +26,4 @@ module.exports = {
"\\.[jt]sx?$": require.resolve("./transform"),
},
watchPathIgnorePatterns: [...ignorePatterns, "\\/node_modules\\/"],
watchPlugins: [
require.resolve("jest-watch-select-projects"),
require.resolve("jest-watch-typeahead/filename"),
require.resolve("jest-watch-typeahead/testname"),
],
Comment on lines -26 to -30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what these were doing but took them out to get rid of these warnings on running jest

Screenshot 2024-04-01 at 2 56 52 PM

Feels smarter to decouple from jest-specific stuff too in anticipation of potentially moving to vitest or node's built-in test runner in the future

};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@rollup/plugin-typescript": "^8.5.0",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.4",
"@types/jsdom": "^21.1.1",
"@types/jsonfile": "^6.1.1",
Expand Down Expand Up @@ -83,8 +84,6 @@
"history": "^5.3.0",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.2",
"jest-watch-select-projects": "^2.0.0",
"jest-watch-typeahead": "^2.2.2",
"jsonfile": "^6.1.0",
"prettier": "^2.8.8",
"prompt-confirm": "^2.0.4",
Expand Down
7 changes: 7 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brought over the node/deno/cloudflare fixtures for the remix-dev tests, but if adapters live elsewhere dunno if these all make sense in here long term (at least deno + cloudflare)?


/.cache
/functions/\[\[path\]\].js
/functions/\[\[path\]\].js.map
/public/build
.dev.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.13.0
22 changes: 22 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Welcome to Remix!

- [Remix Docs](https://remix.run/docs)

## Development

You will be utilizing Wrangler for local development to emulate the Cloudflare runtime. This is already wired up in your package.json as the `dev` script:

```sh
# start the remix dev server and wrangler
npm run dev
```

Open up [http://127.0.0.1:8788](http://127.0.0.1:8788) and you should be ready to go!

## Deployment

Cloudflare Pages are currently only deployable through their Git provider integrations.

If you don't already have an account, then [create a Cloudflare account here](https://dash.cloudflare.com/sign-up/pages) and after verifying your email address with Cloudflare, go to your dashboard and follow the [Cloudflare Pages deployment guide](https://developers.cloudflare.com/pages/framework-guides/deploy-anything).

Configure the "Build command" should be set to `npm run build`, and the "Build output directory" should be set to `public`.
33 changes: 33 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { LinksFunction } from "@remix-run/cloudflare";
import { cssBundleHref } from "@remix-run/css-bundle";
import {
Links,
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";

export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
];

export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { MetaFunction } from "@remix-run/cloudflare";

export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
];
};

export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.8" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/blog"
rel="noreferrer"
>
15m Quickstart Blog Tutorial
</a>
</li>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/jokes"
rel="noreferrer"
>
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
Remix Docs
</a>
</li>
</ul>
</div>
);
}
32 changes: 32 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "remix build",
"dev": "remix dev --manual -c \"npm run start\"",
"start": "wrangler pages dev --compatibility-date=2023-06-21 ./public",
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/cloudflare": "*",
"@remix-run/cloudflare-pages": "*",
"@remix-run/css-bundle": "*",
"@remix-run/react": "*",
"isbot": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20230518.0",
"@remix-run/dev": "*",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"eslint": "^8.38.0",
"typescript": "^5.1.0",
"wrangler": "^3.1.1"
},
"engines": {
"node": ">=18.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/favicon.ico
Cache-Control: public, max-age=3600, s-maxage=3600
/build/*
Cache-Control: public, max-age=31536000, immutable
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"include": ["/*"],
"exclude": ["/favicon.ico", "/build/*"]
}
Binary file not shown.
14 changes: 14 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/remix.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type {import('@remix-run/dev').AppConfig} */
export default {
server: "./server.ts",
serverBuildPath: "functions/[[path]].js",
serverConditions: ["workerd", "worker", "browser"],
serverDependenciesToBundle: "all",
serverMainFields: ["browser", "module", "main"],
serverMinify: true,
serverModuleFormat: "esm",
serverPlatform: "neutral",
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// publicPath: "/build/",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/cloudflare" />
/// <reference types="@cloudflare/workers-types" />
9 changes: 9 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { logDevReady } from "@remix-run/cloudflare";
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";
import * as build from "@remix-run/dev/server-build";

if (process.env.NODE_ENV === "development") {
logDevReady(build);
}

export const onRequest = createPagesFunctionHandler({ build });
22 changes: 22 additions & 0 deletions packages/remix-dev/__tests__/fixtures/cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"target": "ES2022",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},

// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}
6 changes: 6 additions & 0 deletions packages/remix-dev/__tests__/fixtures/deno/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules

/.cache
/build
/public/build
.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["denoland.vscode-deno"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"comment": [
"Resolve NPM imports for `packages/remix-deno`.",
"This import map is used solely for the denoland.vscode-deno extension.",
"Remix does not support import maps.",
"Dependency management is done through `npm` and `node_modules/` instead.",
"Deno-only dependencies may be imported via URL imports (without using import maps)."
],
"imports": {
"@remix-run/css-bundle": "https://esm.sh/@remix-run/[email protected]",
"// `@remix-run/deno` code is already a Deno module, so just get types for it directly from `node_modules/`": "",
"@remix-run/deno": "../node_modules/@remix-run/deno/index.ts",
"@remix-run/dev/server-build": "https://esm.sh/@remix-run/[email protected]/server-build",
"@remix-run/react": "https://esm.sh/@remix-run/[email protected]",
"@remix-run/server-runtime": "https://esm.sh/@remix-run/[email protected]",
"isbot": "https://esm.sh/isbot@^4.1.0",
"react": "https://esm.sh/react@^18.2.0",
"react-dom": "https://esm.sh/react-dom@^18.2.0",
"react-dom/client": "https://esm.sh/react-dom@^18.2.0/client",
"react-dom/server": "https://esm.sh/react-dom@^18.2.0/server"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"deno.enable": true,
"deno.lint": true
}
Loading
Loading