/
alias.spec.ts
51 lines (42 loc) · 1.29 KB
/
alias.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
import { editFile, getColor, untilUpdated } from '../../testUtils'
test('fs', async () => {
expect(await page.textContent('.fs')).toMatch('[success] alias to fs path')
})
test('fs directory', async () => {
expect(await page.textContent('.fs-dir')).toMatch(
'[success] alias to directory'
)
})
test('regex', async () => {
expect(await page.textContent('.regex')).toMatch(
'[success] alias to directory via regex'
)
})
test('dependency', async () => {
expect(await page.textContent('.dep')).toMatch('[success] out of root')
})
test('js via script src', async () => {
expect(await page.textContent('.from-script-src')).toMatch(
'[success] from script src'
)
})
test('css via link', async () => {
expect(await getColor('body')).toBe('grey')
editFile('dir/test.css', (code) => code.replace('grey', 'red'))
await untilUpdated(() => getColor('body'), 'red')
})
test('optimized dep', async () => {
expect(await page.textContent('.optimized')).toMatch(
'[success] alias optimized'
)
})
test('aliased module', async () => {
expect(await page.textContent('.aliased-module')).toMatch(
'[success] aliased module'
)
})
test('custom resolver', async () => {
expect(await page.textContent('.custom-resolver')).toMatch(
'[success] alias to custom-resolver path'
)
})