Skip to content

Commit

Permalink
chore: try to set up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hanspagel committed May 3, 2024
1 parent f3ddf81 commit 7be541c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
run: pnpm build
- name: Check types
run: pnpm types:check
- name: Run tests
run: pnpm test
# - name: Run tests
# run: pnpm test
- name: Deploy to Cloudflare
if: github.ref == 'refs/heads/main'
uses: cloudflare/wrangler-action@v3
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
14 changes: 14 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest'

import app from './index'

describe('index', () => {
it('GET /planets -> JSON', async () => {
const response = await app.request('/planets')

expect(response.status).toBe(200)
expect(await response.json()).toMatchObject({
foo: 'bar',
})
})
})
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import galaxy from '@scalar/galaxy/latest.yaml?raw'
import { createMockServer } from '@scalar/mock-server'

import { renderer } from './renderer'
import galaxy from '@scalar/galaxy/latest.yaml?raw'

// Create the mocked routes
const app = await createMockServer({
Expand Down
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"moduleResolution": "Bundler",
"strict": true,
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types", "vite/client"],
"types": [
"@cloudflare/workers-types",
"vite/client",
"@cloudflare/workers-types/experimental",
"@cloudflare/vitest-pool-workers"
],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
}
Expand Down
11 changes: 11 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'

export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.toml' },
},
},
},
})
7 changes: 5 additions & 2 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name = "galaxy"
pages_build_output_dir = "./dist"
compatibility_date="2024-04-19"
compatibility_flags=["nodejs_compat"]

name="galaxy"
# pages_build_output_dir = "./dist"

# [vars]
# MY_VAR = "my-variable"
Expand Down

0 comments on commit 7be541c

Please sign in to comment.