笑话:找不到以下解决方案:

时间:2019-06-11 04:51:58

标签: javascript node.js multithreading jestjs

当我运行Jest测试时,大约有80%的测试由于

而失败
cannot find resolver for: <config.name>
at getResolver (../node_modules/jest-runner/build/testWorker.js:153:11)

我尝试使用参数runInBand运行测试,但似乎工作得很好,问题是当我尝试使用默认的多线程运行测试时。

  • 我有可能用jest.config弄坏了东西吗?
  • 我不想在单个线程上运行测试

最佳版本-24.8.0

jest.config

module.exports = {
  clearMocks: true,
  collectCoverage: true,
  coverageDirectory: 'coverage',
  coveragePathIgnorePatterns: [
    '/node_modules/',
    '<rootDir>/src/utils/'
  ],
  coverageReporters: [
    'json',
    'html',
    'text',
    'lcov'
  ],
  coverageThreshold: {
    'global': {
      'branches': 35,
      'functions': 41,
      'lines': 55,
      'statements': 53
    }
  },
  globals: {
    _: require('lodash')
  },
  moduleNameMapper: {
    '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/../src/utils/__mocks__//fileMock.js',
    '\\.(css|less|jsf)$': '<rootDir>/../src/utils/__mocks__/styleMock.js',
    '(flags|devices)$': '<rootDir>/../src/utils/__mocks__/styleMock.js'
  },
  roots: [
    '../'
  ],
  setupFiles: [
    '<rootDir>/jest.init.js'
  ],
  snapshotSerializers: ['enzyme-to-json/serializer'],
  testEnvironment: 'node',
  testMatch: [
    '**/__tests__/**/*.spec.js?(x)',
    '**/?(*.)+(spec|test).js?(x)'
  ],
  testPathIgnorePatterns: [
    '/node_modules/',
    '/test/'
  ],
  transformIgnorePatterns: [
    '/node_modules/(?!webapps-frontend-components).+(js|jsx)$'
  ]
}

jest.init

import 'babel-polyfill'
import React from 'react'
import Enzyme, { shallow, render, mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-15'

Enzyme.configure({ adapter: new Adapter() })

global.React = React
global.shallow = shallow
global.render = render
global.mount = mount

0 个答案:

没有答案