-
-
Notifications
You must be signed in to change notification settings - Fork 642
/
Copy pathinternal_helpers.spec.ts
81 lines (69 loc) · 2.54 KB
/
internal_helpers.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* @adonisjs/core
*
* (c) AdonisJS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { test } from '@japa/runner'
import { IgnitorFactory } from '../factories/core/ignitor.js'
import { detectAssetsBundler } from '../src/internal_helpers.js'
test.group('Internal helpers | detect package manager', () => {
test('return "vite" when vite.config.* file exists', async ({ fs, assert }) => {
const app = new IgnitorFactory().create(fs.baseUrl).createApp('web')
await app.init()
await fs.create('vite.config.js', '')
assert.deepEqual(await detectAssetsBundler(app), {
name: 'vite',
devServer: { command: 'vite' },
build: { command: 'vite', args: ['build'] },
})
await fs.remove('vite.config.js')
await fs.create('vite.config.ts', '')
assert.deepEqual(await detectAssetsBundler(app), {
name: 'vite',
devServer: { command: 'vite' },
build: { command: 'vite', args: ['build'] },
})
})
test('return "encore" when webpack.config.* file exists', async ({ fs, assert }) => {
const app = new IgnitorFactory().create(fs.baseUrl).createApp('web')
await app.init()
await fs.create('webpack.config.js', '')
assert.deepEqual(await detectAssetsBundler(app), {
name: 'encore',
devServer: { command: 'encore', args: ['dev-server'] },
build: { command: 'encore', args: ['production'] },
})
await fs.remove('webpack.config.js')
await fs.create('webpack.config.cjs', '')
assert.deepEqual(await detectAssetsBundler(app), {
name: 'encore',
devServer: { command: 'encore', args: ['dev-server'] },
build: { command: 'encore', args: ['production'] },
})
})
test('return undefined when unable to detect', async ({ fs, assert }) => {
const app = new IgnitorFactory().create(fs.baseUrl).createApp('web')
await app.init()
assert.isUndefined(await detectAssetsBundler(app))
})
test('use explicit assetsBundler over detection', async ({ fs, assert }) => {
const app = new IgnitorFactory().create(fs.baseUrl).createApp('web')
app.rcContents({
assetsBundler: {
name: 'webpack',
build: { command: 'webpack' },
devServer: { command: 'webpack dev-server' },
},
})
await app.init()
await fs.create('webpack.config.js', '')
assert.deepEqual(await detectAssetsBundler(app), {
name: 'webpack',
build: { command: 'webpack' },
devServer: { command: 'webpack dev-server' },
})
})
})