mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-02-05 14:38:28 -06:00
* refactor: move jest configs into a preset This could significantly reduce the size of default boilerplate, and gives us more control on the internal config details, thus potentially making future upgrades easier. * fix: add back applyTS
91 lines
2.1 KiB
JavaScript
91 lines
2.1 KiB
JavaScript
const generateWithPlugin = require('@vue/cli-test-utils/generateWithPlugin')
|
|
|
|
test('base', async () => {
|
|
const { pkg, files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-jest',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
// mock presence of the babel & eslint plugin
|
|
{
|
|
id: 'babel',
|
|
apply: () => {},
|
|
options: {}
|
|
},
|
|
{
|
|
id: 'eslint',
|
|
apply: () => {},
|
|
options: {}
|
|
}
|
|
])
|
|
|
|
expect(pkg.scripts['test:unit']).toBe('vue-cli-service test:unit')
|
|
expect(pkg.devDependencies).toHaveProperty('@vue/test-utils')
|
|
|
|
const spec = files['tests/unit/example.spec.js']
|
|
expect(spec).toMatch(`expect(wrapper.text()).toMatch(msg)`)
|
|
})
|
|
|
|
test('with TS', async () => {
|
|
const { files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-jest',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
// mock presence of the ts plugin
|
|
{
|
|
id: 'typescript',
|
|
apply: () => {},
|
|
options: {}
|
|
}
|
|
])
|
|
|
|
const spec = files['tests/unit/example.spec.ts']
|
|
expect(spec).toMatch(`expect(wrapper.text()).toMatch(msg)`)
|
|
})
|
|
|
|
test('bare', async () => {
|
|
const { files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-jest',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
{
|
|
id: '@vue/cli-service',
|
|
apply: () => {},
|
|
options: { bare: true }
|
|
}
|
|
])
|
|
|
|
const spec = files['tests/unit/example.spec.js']
|
|
expect(spec).toMatch(`const wrapper = shallowMount(App)`)
|
|
expect(spec).toMatch(`expect(wrapper.text()).toMatch(\`Welcome to Your Vue.js App\`)`)
|
|
})
|
|
|
|
test('TS + bare', async () => {
|
|
const { files } = await generateWithPlugin([
|
|
{
|
|
id: 'unit-jest',
|
|
apply: require('../generator'),
|
|
options: {}
|
|
},
|
|
{
|
|
id: 'typescript',
|
|
apply: () => {},
|
|
options: {}
|
|
},
|
|
{
|
|
id: '@vue/cli-service',
|
|
apply: () => {},
|
|
options: { bare: true }
|
|
}
|
|
])
|
|
|
|
const spec = files['tests/unit/example.spec.ts']
|
|
expect(spec).toMatch(`const wrapper = shallowMount(App)`)
|
|
expect(spec).toMatch(`expect(wrapper.text()).toMatch(\`Welcome to Your Vue.js + TypeScript App\`)`)
|
|
})
|