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

Implement tests with uvu/swc #104

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions .changeset/fluffy-ladybugs-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"microsite": patch
---

Remove prettier from core dependencies
5 changes: 5 additions & 0 deletions .changeset/late-lions-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"microsite": patch
---

Remove PostCSS logic from core dependencies. Microsite will prompt users to install PostCSS locally if detected.
35 changes: 35 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributing to Microsite

This codebase is a monorepo, set up with [Lerna](https://github.com/lerna/lerna). You should start by familiarizing yourself with `lerna`, as it operates a little bit differently than the standard Node/NPM workflow.

> Note: Commands should generally be run from the root directory of the monorepo rather than a subdirectory like `packages/microsite`.

## Initial dev setup

1. Install [Volta](https://volta.sh/) if you haven't already. It's our favorite tools for managing Node/NPM versions, and automatically picks up the correct Node version for this project.

2. Install dependencies for the monorepo: `npm install`.

3. Install and link dependencies in sub-packages: `npx lerna bootstrap`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see you’ve landed on leaving off hoist, is that intentional? I certainly think it’ll improve the top level dependency flow for now. But just wanted to check that this is actually the preferred flow.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yep, intentional! Seems to work just fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It’s a whole lot less fussy! I will say that I’m certain Yarn (1) would make hoisting work better for perf and a better FS impact. I can almost guarantee PNPM would too, just haven’t tried it. But this is definitely a case where perfection is something I’d avoid solving, I’m just happy to know I’m all good to install a top level dependency without wanting to take a smoke break during the re-bootrappening


## Adding features/fixing bugs
Please open an issue describing your feature/bug before opening a PR.

Please ensure that your PR is covered by a test, if applicable. Microsite currently has very fews tests but this is something we hope to prioritize.

## Testing

Our tests are written in TypeScript with [`uvu`](https://github.com/lukeed/uvu). They are run with the `uvu` CLI and [`@swc-node/register`](https://github.com/Brooooooklyn/swc-node/tree/master/packages/register).

> Note: as of `@swc-node/[email protected]`, `jsxFactory` and `jsxFragmentFactory` are not respected. This means any Preact components need to include the following comment at the top of the file:
> `/* @jsx h */`
> This should be fixed in the next version of `@swc-node/register`.

```bash
npm run test

# Or watch mode (requires a file change to run the first time)
npm run test:watch
```

**VSCode:** There are launch actions included for both single-run and watch mode.
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on: push

jobs:
test:
name: Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: volta-cli/action@v1

- run: npm ci

- run: npm run bootstrap:ci

- run: npm run test
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run tests",
"request": "launch",
"console": "integratedTerminal",
"autoAttachChildProcesses": true,
"runtimeArgs": [
"run-script",
"test"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"name": "Watch tests",
"request": "launch",
"console": "integratedTerminal",
"autoAttachChildProcesses": true,
"runtimeArgs": [
"run-script",
"test:watch"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
]
}
Loading