@@ -9,25 +9,16 @@ const launchPuppeteer = require('@vue/cli-test-utils/launchPuppeteer')
9
9
10
10
let server , browser , page
11
11
test ( 'build as lib' , async ( ) => {
12
- const project = await create ( 'e2e- build-lib' , defaultPreset )
12
+ const project = await create ( 'build-lib' , defaultPreset )
13
13
14
- const { stdout } = await project . run ( 'vue-cli-service build --traget lib --name testLib' )
14
+ const { stdout } = await project . run ( 'vue-cli-service build --target lib --name testLib src/components/HelloWorld.vue ' )
15
15
expect ( stdout ) . toMatch ( 'Build complete.' )
16
16
17
- expect ( project . has ( 'dist/index.html' ) ) . toBe ( true )
18
- expect ( project . has ( 'dist/favicon.ico' ) ) . toBe ( true )
19
- expect ( project . has ( 'dist/js' ) ) . toBe ( true )
20
- expect ( project . has ( 'dist/css' ) ) . toBe ( true )
21
-
22
- const index = await project . read ( 'dist/index.html' )
23
- // should preload app.js & vendor.js
24
- expect ( index ) . toMatch ( / < l i n k r e l = p r e l o a d [ ^ > ] + a p p [ ^ > ] + \. j s > / )
25
- expect ( index ) . toMatch ( / < l i n k r e l = p r e l o a d [ ^ > ] + v e n d o r [ ^ > ] + \. j s > / )
26
-
27
- const vendorFile = index . match ( / < l i n k r e l = p r e l o a d [ ^ > ] + ( v e n d o r [ ^ > ] + \. j s ) > / ) [ 1 ]
28
- const vendor = await project . read ( `dist/js/${ vendorFile } ` )
29
- expect ( vendor ) . toMatch ( `router-link` )
30
- expect ( vendor ) . toMatch ( `vuex` )
17
+ expect ( project . has ( 'dist/demo.html' ) ) . toBe ( true )
18
+ expect ( project . has ( 'dist/testLib.common.js' ) ) . toBe ( true )
19
+ expect ( project . has ( 'dist/testLib.umd.js' ) ) . toBe ( true )
20
+ expect ( project . has ( 'dist/testLib.umd.min.js' ) ) . toBe ( true )
21
+ expect ( project . has ( 'dist/testLib.css' ) ) . toBe ( true )
31
22
32
23
const port = await portfinder . getPortPromise ( )
33
24
server = createServer ( { root : path . join ( project . dir , 'dist' ) } )
@@ -39,15 +30,19 @@ test('build as lib', async () => {
39
30
} )
40
31
} )
41
32
42
- const launched = await launchPuppeteer ( `http://localhost:${ port } /` )
33
+ const launched = await launchPuppeteer ( `http://localhost:${ port } /demo.html ` )
43
34
browser = launched . browser
44
35
page = launched . page
45
36
46
37
const h1Text = await page . evaluate ( ( ) => {
47
38
return document . querySelector ( 'h1' ) . textContent
48
39
} )
40
+ expect ( h1Text ) . toMatch ( '' ) // no props given
49
41
50
- expect ( h1Text ) . toMatch ( 'Welcome to Your Vue.js App' )
42
+ const h2Text = await page . evaluate ( ( ) => {
43
+ return document . querySelector ( 'h2' ) . textContent
44
+ } )
45
+ expect ( h2Text ) . toMatch ( 'Essential Links' )
51
46
} )
52
47
53
48
afterAll ( async ( ) => {
0 commit comments