-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.spec.ts
43 lines (35 loc) · 1.34 KB
/
configure.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { test } from '@japa/runner'
import { fileURLToPath } from 'node:url'
import { IgnitorFactory } from '@adonisjs/core/factories'
import Configure from '@adonisjs/core/commands/configure'
const BASE_URL = new URL('./tmp/', import.meta.url)
test.group('Configure', (group) => {
group.each.setup(({ context }) => {
context.fs.baseUrl = BASE_URL
context.fs.basePath = fileURLToPath(BASE_URL)
})
test('create config file, register provider and update meta files', async ({ fs, assert }) => {
const ignitor = new IgnitorFactory()
.withCoreProviders()
.withCoreConfig()
.create(BASE_URL, {
importer: (filePath) => {
if (filePath.startsWith('./') || filePath.startsWith('../')) {
return import(new URL(filePath, BASE_URL).href)
}
return import(filePath)
},
})
await fs.create('.env', '')
await fs.createJson('tsconfig.json', {})
await fs.create('start/kernel.ts', `router.use([])`)
await fs.create('adonisrc.ts', `export default defineConfig({}) {}`)
const app = ignitor.createApp('web')
await app.init()
await app.boot()
const ace = await app.container.make('ace')
const command = await ace.create(Configure, ['../../index.js'])
await command.exec()
await assert.fileExists('config/geolite2.ts')
}).timeout(60 * 1000)
})