Skip to content

Commit

Permalink
chore: use bun test runner (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge authored Jan 12, 2024
1 parent 231b724 commit 7e32306
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 11,257 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,21 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/[email protected]

- name: Setup Node 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
bun-version: 1.0.21

- name: Install deps (with cache)
run: pnpm install
run: bun install

- name: Build, lint and type-check
run: pnpm turbo build lint typecheck test
run: bun turbo build lint typecheck

- name: Check workspaces
run: pnpm manypkg check
- name: Test
run: bun test
Binary file added bun.lockb
Binary file not shown.
File renamed without changes.
5 changes: 3 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@t3-env/docs",
"type": "module",
"version": "0.1.0",
"private": true,
"scripts": {
Expand All @@ -16,7 +17,7 @@
"class-variance-authority": "^0.4.0",
"clsx": "^1.2.1",
"lucide-react": "0.176.0",
"next": "^13.4.4",
"next": "^14.0.4",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -34,7 +35,7 @@
"@types/react-dom": "18.0.11",
"autoprefixer": "^10.4.13",
"eslint": "^8.39.0",
"eslint-config-next": "^13.4.1",
"eslint-config-next": "^14.0.4",
"postcss": "^8.4.21",
"tailwindcss": "^3.3.1",
"typescript": "^5.0.4"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.js",
"**/*.tsx",
".next/types/**/*.ts",
"next.config.mjs"
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
}
6 changes: 1 addition & 5 deletions examples/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import "./app/env.js";

/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
};
const nextConfig = {};

export default nextConfig;
2 changes: 1 addition & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
"eslint": "^8.39.0",
"next": "^13.4.4",
"next": "^14.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.0.4",
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"name": "@t3-oss/env-root",
"packageManager": "[email protected]",
"packageManager": "[email protected]",
"private": true,
"type": "module",
"workspaces": [
"docs",
"examples/*",
"packages/*"
],
"scripts": {
"build": "turbo build --filter @t3-oss/env*",
"dev": "turbo dev --filter @t3-oss/env*",
Expand All @@ -18,9 +23,10 @@
"@types/node": "^18.15.13",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"bun-types": "^1.0.22",
"eslint": "^8.39.0",
"expect-type": "^0.17.3",
"turbo": "^1.9.3",
"typescript": "^5.0.4",
"vitest": "^0.30.1"
"typescript": "^5.0.4"
}
}
2 changes: 0 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
"build": "rm -rf dist && bunchee",
"dev": "bunhcee -w",
"lint": "eslint . --ext .ts",
"test": "vitest run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
Expand Down
26 changes: 12 additions & 14 deletions packages/core/test/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { expect, expectTypeOf, test, describe } from "vitest";
/// <reference types="bun-types" />
import { expect, test, describe } from "bun:test";
import { expectTypeOf } from "expect-type";

import { createEnv } from "../src/index.js";
import z from "zod";
Expand Down Expand Up @@ -201,7 +203,7 @@ describe("errors when validation fails", () => {
client: { FOO_BAR: z.string() },
runtimeEnv: {},
})
).toThrowErrorMatchingInlineSnapshot(`"Invalid environment variables"`);
).toThrow("Invalid environment variables");
});

test("envs are invalid", () => {
Expand All @@ -215,7 +217,7 @@ describe("errors when validation fails", () => {
FOO_BAR: "foo",
},
})
).toThrowErrorMatchingInlineSnapshot(`"Invalid environment variables"`);
).toThrow("Invalid environment variables");
});

test("with custom error handler", () => {
Expand All @@ -233,9 +235,7 @@ describe("errors when validation fails", () => {
throw new Error(`Invalid variable BAR: ${barError}`);
},
})
).toThrowErrorMatchingInlineSnapshot(`
"Invalid variable BAR: Expected number, received nan"
`);
).toThrow("Invalid variable BAR: Expected number, received nan");
});
});

Expand All @@ -252,8 +252,8 @@ describe("errors when server var is accessed on client", () => {
isServer: false,
});

expect(() => env.BAR).toThrowErrorMatchingInlineSnapshot(
`"❌ Attempted to access a server-side environment variable on the client"`
expect(() => env.BAR).toThrow(
"❌ Attempted to access a server-side environment variable on the client"
);
});

Expand All @@ -272,9 +272,7 @@ describe("errors when server var is accessed on client", () => {
},
});

expect(() => env.BAR).toThrowErrorMatchingInlineSnapshot(
`"Attempted to access BAR on the client"`
);
expect(() => env.BAR).toThrow("Attempted to access BAR on the client");
});
});

Expand Down Expand Up @@ -379,8 +377,8 @@ describe("shared can be accessed on both server and client", () => {

const env = lazyCreateEnv();

expect(() => env.BAR).toThrowErrorMatchingInlineSnapshot(
`"❌ Attempted to access a server-side environment variable on the client"`
expect(() => env.BAR).toThrow(
"❌ Attempted to access a server-side environment variable on the client"
);
expect(env.FOO_BAR).toBe("foo");
expect(env.NODE_ENV).toBe("development");
Expand All @@ -403,7 +401,7 @@ test("envs are readonly", () => {
// expect(() => {
// // @ts-expect-error - envs are readonly
// env.BAR = "foo";
// }).toThrowErrorMatchingInlineSnapshot(
// }).toThrow(
// '"Cannot assign to read only property BAR of object #<Object>"'
// );

Expand Down
2 changes: 0 additions & 2 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
"build": "rm -rf dist && bunchee",
"dev": "bunchee -w",
"lint": "eslint . --ext .ts",
"test": "vitest run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit"
},
"dependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/nextjs/test/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { expect, expectTypeOf, test, describe } from "vitest";
/// <reference types="bun-types" />
import { expect, test, describe } from "bun:test";

import { createEnv } from "../src/index.js";
import z from "zod";
import { expectTypeOf } from "expect-type";

function ignoreErrors(cb: () => void) {
try {
Expand Down
Loading

2 comments on commit 7e32306

@vercel
Copy link

@vercel vercel bot commented on 7e32306 Jan 12, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

t3-env-nextjs – ./examples/nextjs

t3-env-nextjs-t3-oss.vercel.app
t3-env-nextjs.vercel.app
t3-env-nextjs-git-main-t3-oss.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 7e32306 Jan 12, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

t3-env – ./docs

t3-env-git-main-t3-oss.vercel.app
t3-env.vercel.app
t3-env-t3-oss.vercel.app
env.t3.gg
env.t3.wtf

Please sign in to comment.