Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
255 views
in Technique[技术] by (71.8m points)

reactjs - jest is not able to find helper functions

i am using react-mobx store in my react project while running test-case jest is not able to find helper functions that is in my component, getting error: tests/components/common/Sidebar/Sidebar.test.js ● Test suite failed to run

ReferenceError: regeneratorRuntime is not defined
**test.js**

const stores = {
  applicationModel: {},
}

describe('Breadcrumb', () => {
  it('should not render the breadcrumb with no items', () => {
    const properties = {
      breadcrumb: [
        {
          name: '',
          path: '',
          params: {}
        },
        ],
      separator: '',
      applicationModel: {}
    }
    const renderedComponent = shallow(<Breadcrumb.wrappedComponent {...properties}/>)
    const expectedRenderedHTML = <div className='test' />
    expect(renderedComponent).toContainReact(expectedRenderedHTML)
  })
**jest.config.js**

module.exports = {
  verbose: true,
  setupFiles: [
    '<rootDir>/setupTests.js',
    '<rootDir>/src/utils/helpers.js',
    '<rootDir>/src/utils/api.js',
    '<rootDir>/src/utils/functions.js'
  ],
  testRegex: '(/__tests__/.*|(\.|/)test)\.jsx?$',
  moduleNameMapper: {
    '\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js',
  },
  setupTestFrameworkScriptFile: '<rootDir>/node_modules/jest-enzyme/lib/index.js',
  transform: {
    '.*': '<rootDir>/node_modules/babel-jest',
  },
  collectCoverage: true,
}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...