mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-17 11:15:14 +00:00
a616c09b22
* feat(test): enable tests in packages * fix: wait error hook * test: entry and hookable in core * fix(test): options snapshot in windows * refactor(test): simpilify jest.fn * test: module in core * test: complete module test * test: add test for resolver in core * test: update config snapshot * test: nuxt in core module
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import { run } from '../../src'
|
|
import getCommand from '../../src/commands'
|
|
|
|
jest.mock('../../src/commands')
|
|
|
|
describe('cli', () => {
|
|
afterEach(() => jest.resetAllMocks())
|
|
|
|
test('calls expected method', async () => {
|
|
const mockedCommand = {
|
|
run: jest.fn(() => Promise.resolve({}))
|
|
}
|
|
getCommand.mockImplementationOnce(() => Promise.resolve(mockedCommand))
|
|
|
|
await run()
|
|
expect(mockedCommand.run).toHaveBeenCalled()
|
|
})
|
|
|
|
test('sets NODE_ENV=development for dev', async () => {
|
|
const nodeEnv = process.env.NODE_ENV
|
|
process.env.NODE_ENV = ''
|
|
|
|
getCommand.mockImplementationOnce(() => Promise.resolve({}))
|
|
|
|
await run(['dev'])
|
|
expect(process.env.NODE_ENV).toBe('development')
|
|
process.env.NODE_ENV = nodeEnv
|
|
})
|
|
|
|
test('sets NODE_ENV=production for build', async () => {
|
|
const nodeEnv = process.env.NODE_ENV
|
|
process.env.NODE_ENV = ''
|
|
|
|
getCommand.mockImplementationOnce(() => Promise.resolve({}))
|
|
|
|
await run(['', '', 'build'])
|
|
expect(process.env.NODE_ENV).toBe('production')
|
|
|
|
process.env.NODE_ENV = nodeEnv
|
|
})
|
|
})
|