first commit
This commit is contained in:
commit
3d7faf9723
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
dist
|
||||||
|
.solid
|
||||||
|
.output
|
||||||
|
.vercel
|
||||||
|
.netlify
|
||||||
|
netlify
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
|
||||||
|
# Temp
|
||||||
|
gitignore
|
||||||
|
|
||||||
|
# System Files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
|
@ -0,0 +1,41 @@
|
||||||
|
# SolidStart
|
||||||
|
|
||||||
|
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
|
||||||
|
|
||||||
|
## Creating a project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# create a new project in the current directory
|
||||||
|
npm init solid@latest
|
||||||
|
|
||||||
|
# create a new project in my-app
|
||||||
|
npm init solid@latest my-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# or start the server and open the app in a new browser tab
|
||||||
|
npm run dev -- --open
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
Solid apps are built with _adapters_, which optimise your project for deployment to different environments.
|
||||||
|
|
||||||
|
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.
|
||||||
|
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
Tests are written with `vitest`, `@solidjs/testing-library` and `@testing-library/jest-dom` to extend expect with some helpful custom matchers.
|
||||||
|
|
||||||
|
To run them, simply start:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test
|
||||||
|
```
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
preset: "solid-jest/preset/browser",
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "backend",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "solid-start dev",
|
||||||
|
"build": "solid-start build",
|
||||||
|
"start": "solid-start start",
|
||||||
|
"test": "vitest run",
|
||||||
|
"test-watch": "vitest",
|
||||||
|
"test-ui": "vitest --ui",
|
||||||
|
"coverage": "vitest run --coverage"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"devDependencies": {
|
||||||
|
"@solidjs/meta": "^0.28.2",
|
||||||
|
"@solidjs/router": "^0.7.0",
|
||||||
|
"@solidjs/testing-library": "^0.5.2",
|
||||||
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
|
"@types/testing-library__jest-dom": "^5.14.5",
|
||||||
|
"@vitest/coverage-c8": "^0.26.3",
|
||||||
|
"@vitest/ui": "^0.26.3",
|
||||||
|
"jsdom": "^20.0.3",
|
||||||
|
"solid-js": "^1.6.11",
|
||||||
|
"solid-start": "^0.2.19",
|
||||||
|
"solid-start-node": "^0.2.19",
|
||||||
|
"typescript": "^4.9.4",
|
||||||
|
"undici": "^5.15.1",
|
||||||
|
"vite": "^3.2.5",
|
||||||
|
"vitest": "^0.26.3"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 664 B |
|
@ -0,0 +1 @@
|
||||||
|
import "@testing-library/jest-dom";
|
|
@ -0,0 +1,20 @@
|
||||||
|
.increment {
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
padding: 1em 2em;
|
||||||
|
color: #335d92;
|
||||||
|
background-color: rgba(68, 107, 158, 0.1);
|
||||||
|
border-radius: 2em;
|
||||||
|
border: 2px solid rgba(68, 107, 158, 0);
|
||||||
|
outline: none;
|
||||||
|
width: 200px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.increment:focus {
|
||||||
|
border: 2px solid #335d92;
|
||||||
|
}
|
||||||
|
|
||||||
|
.increment:active {
|
||||||
|
background-color: rgba(68, 107, 158, 0.2);
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { fireEvent, render } from "@solidjs/testing-library";
|
||||||
|
import Counter from "./Counter";
|
||||||
|
|
||||||
|
describe("<Counter />", () => {
|
||||||
|
it("increments value", async () => {
|
||||||
|
const { queryByRole, unmount } = render(() => <Counter />);
|
||||||
|
const button = (await queryByRole("button")) as HTMLButtonElement;
|
||||||
|
expect(button).toBeInTheDocument();
|
||||||
|
expect(button).toHaveTextContent(/Clicks: 0/);
|
||||||
|
fireEvent.click(button);
|
||||||
|
expect(button).toHaveTextContent(/Clicks: 1/);
|
||||||
|
unmount();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders 1", () => {
|
||||||
|
const { container, unmount } = render(() => <Counter />);
|
||||||
|
expect(container).toMatchSnapshot();
|
||||||
|
unmount();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { createSignal } from "solid-js";
|
||||||
|
import "./Counter.css";
|
||||||
|
|
||||||
|
export default function Counter() {
|
||||||
|
const [count, setCount] = createSignal(0);
|
||||||
|
return (
|
||||||
|
<button class="increment" onClick={() => setCount(count() + 1)}>
|
||||||
|
Clicks: {count()}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Vitest Snapshot v1
|
||||||
|
|
||||||
|
exports[`<Counter /> > renders 1 1`] = `
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
class="increment"
|
||||||
|
>
|
||||||
|
Clicks:
|
||||||
|
<!--#-->
|
||||||
|
0
|
||||||
|
<!--/-->
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { mount, StartClient } from "solid-start/entry-client";
|
||||||
|
|
||||||
|
mount(() => <StartClient />, document);
|
|
@ -0,0 +1,9 @@
|
||||||
|
import {
|
||||||
|
StartServer,
|
||||||
|
createHandler,
|
||||||
|
renderAsync,
|
||||||
|
} from "solid-start/entry-server";
|
||||||
|
|
||||||
|
export default createHandler(
|
||||||
|
renderAsync((event) => <StartServer event={event} />)
|
||||||
|
);
|
|
@ -0,0 +1,35 @@
|
||||||
|
// @refresh reload
|
||||||
|
import { Routes } from "@solidjs/router";
|
||||||
|
import { Suspense } from "solid-js";
|
||||||
|
import {
|
||||||
|
Body,
|
||||||
|
FileRoutes,
|
||||||
|
Head,
|
||||||
|
Html,
|
||||||
|
Meta,
|
||||||
|
Scripts,
|
||||||
|
Title,
|
||||||
|
} from "solid-start";
|
||||||
|
import { ErrorBoundary } from "solid-start/error-boundary";
|
||||||
|
|
||||||
|
export default function Root() {
|
||||||
|
return (
|
||||||
|
<Html lang="en">
|
||||||
|
<Head>
|
||||||
|
<Title>SolidStart - With Vitest</Title>
|
||||||
|
<Meta charset="utf-8" />
|
||||||
|
<Meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
</Head>
|
||||||
|
<Body>
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<Routes>
|
||||||
|
<FileRoutes />
|
||||||
|
</Routes>
|
||||||
|
</ErrorBoundary>
|
||||||
|
</Suspense>
|
||||||
|
<Scripts />
|
||||||
|
</Body>
|
||||||
|
</Html>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
body {
|
||||||
|
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell,
|
||||||
|
'Open Sans', 'Helvetica Neue', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
text-align: center;
|
||||||
|
padding: 1em;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #335d92;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 4rem;
|
||||||
|
font-weight: 100;
|
||||||
|
line-height: 1.1;
|
||||||
|
margin: 4rem auto;
|
||||||
|
max-width: 14rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
max-width: 14rem;
|
||||||
|
margin: 2rem auto;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 480px) {
|
||||||
|
h1 {
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import Counter from "~/components/Counter";
|
||||||
|
import "./index.css";
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<h1>Hello world!</h1>
|
||||||
|
<Counter />
|
||||||
|
<p>
|
||||||
|
Visit{" "}
|
||||||
|
<a href="https://solidjs.com" target="_blank">
|
||||||
|
solidjs.com
|
||||||
|
</a>{" "}
|
||||||
|
to learn how to build Solid apps.
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsxImportSource": "solid-js",
|
||||||
|
"jsx": "preserve",
|
||||||
|
"strict": true,
|
||||||
|
"types": ["solid-start/env", "@testing-library/jest-dom"],
|
||||||
|
"baseUrl": "./",
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"types": ["vitest"]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import solid from "solid-start/vite";
|
||||||
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [solid()],
|
||||||
|
});
|
|
@ -0,0 +1,22 @@
|
||||||
|
import solid from "solid-start/vite";
|
||||||
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [solid()],
|
||||||
|
test: {
|
||||||
|
deps: {
|
||||||
|
registerNodeLoader: true,
|
||||||
|
inline: [/solid-js/],
|
||||||
|
},
|
||||||
|
environment: "jsdom",
|
||||||
|
globals: true,
|
||||||
|
setupFiles: [
|
||||||
|
"node_modules/@testing-library/jest-dom/extend-expect",
|
||||||
|
"./setupVitest.js",
|
||||||
|
],
|
||||||
|
transformMode: { web: [/\.[jt]sx?$/] },
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
conditions: ["development", "browser"],
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue