自从我尝试开始使用 Jest 以来,我一直遇到困难。我没有尝试运行任何测试,也没有尝试通过 Jest 的选项,但我从未在控制台中得到“通过”/“失败”输出结果。
Jest 总是只输出“完成”
使用“Nuxt CLI”,有一个默认测试编写为:
import { mount } from '@vue/test-utils'
import Logo from '@/components/Logo.vue'
describe('Logo', () => {
test('is a Vue instance', () => {
const wrapper = mount(Logo)
expect(wrapper.isVueInstance()).toBeTruthy()
})
})
到目前为止我已经尝试过:
yarn test
yarn test --verbose
yarn test --watch
yarn test --watchAll
yarn test --no-watchmen
每次的结果如下:
yarn run v1.21.1
$ jest
Done in 0.72s.
当前jest.config.js:
module.exports = {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
'^~/(.*)$': '<rootDir>/$1',
'^vue$': 'vue/dist/vue.common.js'
},
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
},
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/components/**/*.vue',
'<rootDir>/pages/**/*.vue'
]
}
这似乎是 Nuxt 的默认配置。
如有任何帮助,我们将不胜感激
最佳答案
所以我想通了(有点)。
我的测试运行良好,如下所示:
yarn test --no-watchman
我不明白为什么守望者给我带来了这么多问题,但这似乎确实有帮助。
关于javascript - 开 Jest - 没有输出测试结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59749452/