-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add hub
test
env as well as supporting nuxt test option (#429)
- Loading branch information
Showing
3 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { describe, it, expect } from 'vitest' | ||
import { setup, $fetch } from '@nuxt/test-utils/e2e' | ||
|
||
describe('ssr', async () => { | ||
await setup({ | ||
rootDir: fileURLToPath(new URL('..', import.meta.url)), | ||
dev: true | ||
}) | ||
|
||
it('Clear todos table', async () => { | ||
await $fetch('/api/_hub/database/query', { | ||
method: 'POST', | ||
body: { | ||
query: 'DELETE FROM todos' | ||
} | ||
}) | ||
}) | ||
|
||
it('List todos', async () => { | ||
const todos = await $fetch('/api/todos') | ||
expect(todos).toMatchObject([]) | ||
}) | ||
|
||
it('Create todo', async () => { | ||
const todo = await $fetch('/api/todos', { | ||
method: 'POST', | ||
body: { title: 'Test todo' } | ||
}) | ||
expect(todo).toMatchObject({ id: expect.any(Number), title: 'Test todo' }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters