-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor cli integration tests (#6537)
- Loading branch information
Showing
6 changed files
with
62 additions
and
36 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
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import consola from 'consola' | ||
|
||
export default { | ||
test: true, | ||
mode: 'spa', | ||
hooks (hook) { | ||
hook('build:done', () => { | ||
process.stdout.write('Compiled successfully') | ||
consola.log('Compiled successfully') | ||
}) | ||
hook('listen', (server, { port, host }) => { | ||
process.stdout.write(`Listening on http://${host}:${port}`) | ||
consola.log(`Listening on http://${host}:${port}`) | ||
}) | ||
}, | ||
build: { | ||
terser: false | ||
} | ||
} |
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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { exec } from 'child_process' | ||
import { resolve } from 'path' | ||
import { promisify } from 'util' | ||
|
||
const execify = promisify(exec) | ||
const rootDir = __dirname | ||
const nuxtBin = resolve(__dirname, '../../../packages/cli/bin/nuxt.js') | ||
import { NuxtCommand, commands } from '@nuxt/cli' | ||
import consola from 'consola' | ||
|
||
describe('cli build', () => { | ||
test.skip('nuxt build', async () => { | ||
const { stdout } = await execify(`node -r esm ${nuxtBin} build ${rootDir} -c cli.build.config.js`) | ||
test('nuxt build', async () => { | ||
const buildCommand = await commands.default('build') | ||
|
||
const argv = [ | ||
__dirname, | ||
'--no-force-exit', | ||
'-c', | ||
'cli.build.config.js' | ||
] | ||
|
||
expect(stdout.includes('Compiled successfully')).toBe(true) | ||
}, 80000) | ||
const cmd = new NuxtCommand(buildCommand, argv) | ||
await expect(cmd.run()).resolves.toBeUndefined() | ||
|
||
test.skip('nuxt build -> error config', async () => { | ||
await expect(execify(`node -r esm ${nuxtBin} build ${rootDir} -c config.js`)).rejects.toMatchObject({ | ||
stderr: expect.stringContaining('Could not load config file: config.js') | ||
}) | ||
expect(consola.log).toBeCalledWith('Compiled successfully') | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import { exec } from 'child_process' | ||
import { resolve } from 'path' | ||
import { promisify } from 'util' | ||
|
||
const execify = promisify(exec) | ||
const rootDir = __dirname | ||
const nuxtBin = resolve(__dirname, '../../../packages/cli/bin/nuxt.js') | ||
import { NuxtCommand, commands } from '@nuxt/cli' | ||
import consola from 'consola' | ||
|
||
describe('cli generate', () => { | ||
test.skip('nuxt generate', async () => { | ||
const { stdout } = await execify(`node -r esm ${nuxtBin} generate ${rootDir} -c cli.gen.config.js`) | ||
test('nuxt generate', async () => { | ||
const generateCommand = await commands.default('generate') | ||
|
||
const argv = [ | ||
__dirname, | ||
'--no-force-exit', | ||
'-c', | ||
'cli.gen.config.js' | ||
] | ||
|
||
const cmd = new NuxtCommand(generateCommand, argv) | ||
await expect(cmd.run()).resolves.toBeUndefined() | ||
|
||
expect(stdout.includes('Generated successfully')).toBe(true) | ||
}, 80000) | ||
expect(consola.log).toBeCalledWith('Generated successfully') | ||
}) | ||
}) |