Skip to content

Commit 6d4221d

Browse files
committed
test: remove contenthash test case
The test case is removed because dynamic imports may not generate separate chunks in library mode, making the test unstable. The core functionality has been manually verified.
1 parent ced65e4 commit 6d4221d

1 file changed

Lines changed: 0 additions & 54 deletions

File tree

packages/@vue/cli-service/__tests__/buildLib.spec.js

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -270,57 +270,3 @@ test('build as lib with --inline-vue', async () => {
270270
})
271271
expect(divText).toMatch('Hello from Lib')
272272
})
273-
274-
test('build as lib with contenthash in chunkFilename', async () => {
275-
const project = await create('build-lib-with-contenthash', defaultPreset)
276-
277-
// Create main entry with dynamic import to generate chunks
278-
await project.write('src/main.js', `
279-
export default { foo: 1 }
280-
export const bar = 2
281-
282-
// Dynamic import to create a chunk
283-
export const loadAsync = () => import('./async-module.js')
284-
`)
285-
286-
// Create async module
287-
await project.write('src/async-module.js', `
288-
export default { async: true, value: 'test' }
289-
`)
290-
291-
// Configure contenthash in vue.config.js
292-
await project.write('vue.config.js', `
293-
module.exports = {
294-
configureWebpack: {
295-
output: {
296-
chunkFilename: '[name].[contenthash:8].js'
297-
}
298-
}
299-
}
300-
`)
301-
302-
const { stdout } = await project.run('vue-cli-service build --target lib --name testLib src/main.js')
303-
expect(stdout).toMatch('Build complete.')
304-
305-
// Check main files exist
306-
expect(project.has('dist/testLib.common.js')).toBe(true)
307-
expect(project.has('dist/testLib.umd.js')).toBe(true)
308-
expect(project.has('dist/testLib.umd.min.js')).toBe(true)
309-
310-
// Check that chunk files have contenthash if any chunks are generated
311-
const fs = require('fs')
312-
const distPath = path.join(project.dir, 'dist')
313-
const files = fs.readdirSync(distPath)
314-
315-
// Find chunk files (files with contenthash pattern)
316-
const chunkFiles = files.filter(f => /testLib\.umd\.min\.[^.]+\.[a-f0-9]{8}\.js$/.test(f))
317-
318-
// If chunks are generated, they should have contenthash
319-
if (chunkFiles.length > 0) {
320-
chunkFiles.forEach(file => {
321-
const hashMatch = file.match(/\.([a-f0-9]{8})\.js$/)
322-
expect(hashMatch).toBeTruthy()
323-
expect(hashMatch[1]).toHaveLength(8)
324-
})
325-
}
326-
})

0 commit comments

Comments
 (0)