-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/fixtures/filenames-query-part/filenames-query-part.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { buildFixture } from '../../utils/build' | ||
|
||
buildFixture('filenames-query-part') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
build: { | ||
filenames: { | ||
app: '[name].js?v=[contenthash]', | ||
chunk: '[name].js?v=[contenthash]' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div> | ||
<h1>Chunks with version in query part</h1> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { resolve } from 'path' | ||
import { existsSync, readFileSync } from 'fs' | ||
import { getPort, loadFixture, Nuxt } from '../utils' | ||
|
||
let port | ||
|
||
let nuxt = null | ||
|
||
expect.extend({ | ||
toFileExist(file) { | ||
if (existsSync(file)) { | ||
return { | ||
message: () => `expected '${file}' not exist`, | ||
pass: true | ||
} | ||
} else { | ||
return { | ||
message: () => `expected '${file}' exist`, | ||
pass: false | ||
} | ||
} | ||
} | ||
}) | ||
|
||
describe('build filenames with query part', () => { | ||
beforeAll(async () => { | ||
const config = await loadFixture('filenames-query-part') | ||
nuxt = new Nuxt(config) | ||
port = await getPort() | ||
await nuxt.server.listen(port, 'localhost') | ||
}) | ||
|
||
test('server manifest files exist', () => { | ||
const manifest = JSON.parse(readFileSync(resolve(__dirname, '..', 'fixtures/filenames-query-part/.nuxt/dist/server/server.manifest.json'), 'utf8')) | ||
expect(manifest).toMatchObject({ | ||
files: expect.any(Object) | ||
}) | ||
for (const file in manifest.files) { | ||
expect(resolve(__dirname, '..', `fixtures/filenames-query-part/.nuxt/dist/server/${manifest.files[file]}`)).toFileExist() | ||
} | ||
}) | ||
|
||
test("render / without error 'Cannot find module'", async () => { | ||
await expect(nuxt.server.renderRoute('/')).resolves.toMatchObject({ | ||
html: expect.stringContaining('<h1>Chunks with version in query part</h1>') | ||
}) | ||
}) | ||
|
||
// Close server and ask nuxt to stop listening to file changes | ||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
}) |