Skip to content

Commit

Permalink
tests: add tests infrastructure + first unit and e2e tests (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurijmikhalevich authored Apr 28, 2024
1 parent 7d9678e commit 6891169
Show file tree
Hide file tree
Showing 22 changed files with 2,075 additions and 1,290 deletions.
1 change: 1 addition & 0 deletions .env.e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=file:/tmp/aibyss-test.db
12 changes: 12 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ jobs:
- run: npm ci
- run: npm run lint
- run: npm run build

test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm ci
- run: npm run test:e2e:install
- run: npm run test
- run: npm run test:e2e
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ logs
.env
.env.*
!.env.example
!.env.e2e

# Data Base
dev.db
dev.db-journal

test-results
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,25 @@ Start the development server on `http://localhost:3000`:
npm run dev
```

## Running the tests

### unit tests

```bash
npm run test
```

### e2e tests

First, setup e2e tests by running `npm run test:e2e:install`, then run the tests with:

```bash
npm run test:e2e
```

## Contributors guide

- we follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), name your PRs accordingly
We follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), name your PRs accordingly

## Production

Expand Down
3 changes: 3 additions & 0 deletions bin/seed-test-users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { seedTestUsers } from "../tests/utils/seed-test-users";

seedTestUsers();
5 changes: 4 additions & 1 deletion components/CodeEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ function onSubmit(event: Event) {
</script>

<template>
<div class="w-full h-full font-sans">
<div
class="w-full h-full font-sans"
data-testid="code-editor"
>
<form
class="flex h-full flex-col"
@submit="onSubmit"
Expand Down
5 changes: 4 additions & 1 deletion components/GameScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ watch(gameState, (newState) => {
</script>

<template>
<div class="h-full w-full">
<div
class="h-full w-full"
data-testid="game-screen"
>
<canvas ref="canvas" />
</div>
</template>
10 changes: 10 additions & 0 deletions components/GlobalHeader.nuxt.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { mountSuspended } from "@nuxt/test-utils/runtime";

import { it, expect } from "vitest";

import GlobalHeader from "./GlobalHeader.vue";

it("mounts the GlobalHeader component", async () => {
const component = await mountSuspended(GlobalHeader);
expect(component.text()).toEqual("Aibyss");
});
7 changes: 5 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
app: {
head: {
Expand All @@ -9,11 +8,15 @@ export default defineNuxtConfig({
},
devtools: { enabled: true },
css: ["~/assets/css/main.css"],
modules: ["nuxt-monaco-editor", "@nuxt/eslint"],
modules: ["nuxt-monaco-editor", "@nuxt/eslint", "@nuxt/test-utils/module"],
nitro: {
hooks: {
"dev:reload": () => require("isolated-vm"),
},
serverAssets: [{
baseName: "botApis",
dir: "./botApis",
}],
},
postcss: {
plugins: {
Expand Down
Loading

0 comments on commit 6891169

Please sign in to comment.