javascript - 开 Jest - 没有输出测试结果

标签 javascript node.js jestjs yarnpkg

自从我尝试开始使用 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

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

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

关于javascript - 开 Jest - 没有输出测试结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59749452/

相关文章:

javascript - 存储 href 的文本部分以在 php 中使用

javascript - 如何将ID发送到数据库以便在回调函数中进行搜索

javascript - 不知道如何异步

node.js - 使用 Node : Unknown file extension ".ts" 在 VSCode 中调试 TS

javascript - Sequelize.js setter 函数没有按我的预期工作

javascript - 使用Javascript和PHP进行表单验证

javascript - 在一页上使用多个图像/链接在文本悬停上隐藏和显示图像

javascript - 使用 Enzyme 测试点击监听器

javascript - 运行包含 CoffeeScript 文件导入的 Jest 测试时出现语法错误

jestjs - Jest toMatchSnapshot 不会引发异常