Skip to content

Commit

Permalink
refactor(test): change to not use env command (#2062)
Browse files Browse the repository at this point in the history
* refactor(test): change to not use `env` command

* fix bun test
  • Loading branch information
ryuapp authored Jan 23, 2024
1 parent 39aa582 commit 45d612d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"scripts": {
"test": "tsc --noEmit && vitest --run",
"test:watch": "vitest --watch",
"test:deno": "env NAME=Deno deno test --allow-read --allow-env runtime_tests/deno && deno test --no-lock -c runtime_tests/deno-jsx/deno.precompile.json runtime_tests/deno-jsx && deno test --no-lock -c runtime_tests/deno-jsx/deno.react-jsx.json runtime_tests/deno-jsx",
"test:bun": "env NAME=Bun bun test --jsx-import-source ../../src/jsx runtime_tests/bun/index.test.tsx",
"test:deno": "deno test --allow-read --allow-env runtime_tests/deno && deno test --no-lock -c runtime_tests/deno-jsx/deno.precompile.json runtime_tests/deno-jsx && deno test --no-lock -c runtime_tests/deno-jsx/deno.react-jsx.json runtime_tests/deno-jsx",
"test:bun": "bun test --jsx-import-source ../../src/jsx runtime_tests/bun/index.test.tsx",
"test:fastly": "vitest --run --config ./runtime_tests/fastly/vitest.config.ts",
"test:lagon": "start-server-and-test \"lagon dev runtime_tests/lagon/index.ts -e runtime_tests/lagon/.env.lagon\" http://127.0.0.1:1234 \"yarn vitest --run runtime_tests/lagon/index.test.ts --config runtime_tests/lagon/vitest.config.ts\"",
"test:node": "env NAME=Node vitest --run --config ./runtime_tests/node/vitest.config.ts",
"test:node": "vitest --run --config ./runtime_tests/node/vitest.config.ts",
"test:wrangler": "vitest --run --config ./runtime_tests/wrangler/vitest.config.ts",
"test:lambda": "env NAME=Node vitest --run --config ./runtime_tests/lambda/vitest.config.ts",
"test:lambda-edge": "env NAME=Node vitest --run --config ./runtime_tests/lambda-edge/vitest.config.ts",
"test:lambda": "vitest --run --config ./runtime_tests/lambda/vitest.config.ts",
"test:lambda-edge": "vitest --run --config ./runtime_tests/lambda-edge/vitest.config.ts",
"test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:lagon && yarn test:node && yarn test:wrangler && yarn test:lambda && yarn test:lambda-edge",
"lint": "eslint --ext js,ts src runtime_tests",
"lint:fix": "eslint --ext js,ts src runtime_tests --fix",
Expand Down
2 changes: 2 additions & 0 deletions runtime_tests/bun/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { HonoRequest } from '../../src/request'
// Test just only minimal patterns.
// Because others are tested well in Cloudflare Workers environment already.

Bun.env.NAME = 'Bun'

describe('Basic', () => {
const app = new Hono()
app.get('/a/:foo', (c) => {
Expand Down
2 changes: 2 additions & 0 deletions runtime_tests/deno/hono.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { assertEquals } from './deps.ts'
// Test just only minimal patterns.
// Because others are tested well in Cloudflare Workers environment already.

Deno.env.set('NAME', 'Deno')

Deno.test('Hello World', async () => {
const app = new Hono()
app.get('/:foo', (c) => {
Expand Down
3 changes: 3 additions & 0 deletions runtime_tests/lambda-edge/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
env: {
NAME: 'Node',
},
globals: true,
include: ['**/runtime_tests/lambda-edge/**/*.+(ts|tsx|js)'],
exclude: ['**/runtime_tests/lambda-edge/vitest.config.ts'],
Expand Down
3 changes: 3 additions & 0 deletions runtime_tests/lambda/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
env: {
NAME: 'Node',
},
globals: true,
include: ['**/runtime_tests/lambda/**/*.+(ts|tsx|js)'],
exclude: ['**/runtime_tests/lambda/vitest.config.ts', '**/runtime_tests/lambda/mock.ts'],
Expand Down
3 changes: 3 additions & 0 deletions runtime_tests/node/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
env: {
NAME: 'Node',
},
globals: true,
include: ['**/runtime_tests/node/**/*.+(ts|tsx|js)'],
exclude: ['**/runtime_tests/node/vitest.config.ts'],
Expand Down

0 comments on commit 45d612d

Please sign in to comment.