Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
test: fix tests app termination
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwanp committed Sep 28, 2024
1 parent 5fe46aa commit 8cb17c6
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 207 deletions.
11 changes: 9 additions & 2 deletions bin/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ import 'reflect-metadata'
import { assert } from '@japa/assert'
import { expectTypeOf } from '@japa/expect-type'
import { processCLIArgs, configure, run } from '@japa/runner'
import { createApp } from '../tests/functional/app.js'
import { createApp } from '../tests/integration/app.js'
import { fileSystem } from '@japa/file-system'
import app from '@adonisjs/core/services/app'
import { ApplicationService } from '@adonisjs/core/types'

let testApp: ApplicationService
processCLIArgs(process.argv.slice(2))
configure({
suites: [
{
name: 'units',
files: ['tests/units/**/*.spec.(js|ts)'],
},
{
name: 'integration',
files: ['tests/integration/**/*.spec.(js|ts)'],
},
{
name: 'functional',
files: ['tests/functional/**/*.spec.(js|ts)'],
Expand All @@ -21,12 +27,13 @@ configure({
plugins: [assert(), expectTypeOf(), fileSystem()],
setup: [
async () => {
await createApp()
testApp = await createApp()
},
],
teardown: [
async () => {
await app.terminate()
await testApp.terminate()
},
],
})
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@
"@types/node": "^20.14.5",
"@types/sinon": "^17.0.3",
"algoliasearch": "^5.6.1",
"better-sqlite3": "^11.3.0",
"c8": "^10.1.2",
"copyfiles": "^2.4.1",
"del-cli": "^5.1.0",
"eslint": "^9.9.0",
"luxon": "^3.5.0",
"meilisearch": "^0.42.0",
"np": "^10.0.6",
"prettier": "^3.3.2",
Expand All @@ -81,8 +83,7 @@
"testcontainers": "^10.13.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typesense": "^1.8.2",
"luxon": "^3.5.0"
"typesense": "^1.8.2"
},
"peerDependencies": {
"@adonisjs/core": "^6.2.0",
Expand Down
2 changes: 0 additions & 2 deletions src/engines/typesense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export class TypesenseEngine implements MagnifyEngine {
const Static = models[0].constructor as SearchableModel
const collection = await this.#getOrCreateCollectionFromModel(Static)

console.log('removed models', models)

await Promise.all(
models.map((model) => collection.documents(model.$searchKeyValue.toString()).delete())
)
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/configuration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Configure from '@adonisjs/core/commands/configure'
import { IgnitorFactory } from '@adonisjs/core/factories'
import { ApplicationService } from '@adonisjs/core/types'
import { FileSystem } from '@japa/file-system'
import { test } from '@japa/runner'
import { fileURLToPath } from 'node:url'
Expand All @@ -21,7 +20,7 @@ async function configure(fs: FileSystem, choice: number) {
},
})

const app = ignitor.createApp('web')
const app = ignitor.createApp('console')
await app.init()
await app.boot()

Expand Down Expand Up @@ -53,6 +52,8 @@ test.group('Configuration', (group) => {
context.fs.basePath = fileURLToPath(BASE_URL)
})

group.each.disableTimeout()

test('configure algolia engine', async ({ fs, assert }) => {
await configure(fs, 0)

Expand Down
56 changes: 0 additions & 56 deletions tests/functional/meilisearch.spec.ts

This file was deleted.

138 changes: 0 additions & 138 deletions tests/functional/typesense.spec.ts

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions tests/functional/app.ts → tests/integration/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export async function createApp() {
new URL('../fixtures/migrations/create_users_table.ts', import.meta.url),
testApp.migrationsPath('create_users_table.ts')
)

return testApp
}

export async function initializeDatabase(app: ApplicationService) {
Expand Down Expand Up @@ -104,8 +106,6 @@ async function seedDatabase() {
yield { name: 'Amos Larson Sr.' }
}

// for (let i = 0; i < 44; i++) {
const toCreate = [...collection()]
await User.createMany(toCreate)
// }
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8cb17c6

Please sign in to comment.