首页 > 解决方案 > 开玩笑 - 不输出测试结果

问题描述

自从我尝试开始使用 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 的默认配置。

任何帮助,将不胜感激

标签: javascriptnode.jsjestjsyarnpkg

解决方案


所以我想通了(有点)。

我的测试在以下情况下运行良好:

yarn test --no-watchman

我不明白为什么守望者给我带来了这么多问题,但这似乎确实有帮助。

更多信息: https ://github.com/facebook/jest/issues/2219


推荐阅读