Jest: Jest loads ignored folder in package.json

Created on 2 Feb 2017  路  7Comments  路  Source: facebook/jest

Jest display this message:

jest-haste-map: @providesModule naming collision:
  Duplicate module name: template
  Paths: /Users/brunoquaresma/workspace/publisher_client/package.json collides with /Users/brunoquaresma/workspace/publisher_client/deploy/package.json

This warning is caused by a @providesModule declaration with the same name across two different files.

It is loading my deploy folder that I ignore in package.json

"testPathIgnorePatterns": [
      "<rootDir>[/\\\\](build|docs|node_modules|deploy|scripts)[/\\\\]"
    ],

And... it is very very very slow. To run 3 simple tests it spent 44 seconds to start.

Most helpful comment

Have you tried using modulePathIgnorePatterns?

All 7 comments

Have you tried using modulePathIgnorePatterns?

I try.:

"modulePathIgnorePatterns": [
      "<rootDir>[/\\\\](build|docs|node_modules|deploy|scripts)[/\\\\]"
    ],

the message disappears but the tests still slow

captura de tela 2017-02-03 as 15 04 03

New.test.js example.

import React from 'react'
import AutomaticForm from '_components/Applications/AutomaticForm'
import Form from '_components/Applications/Form'
import { NewApplications } from './../New'
import { shallow } from 'enzyme'
import { Pills, Pill } from 'supernova-inloco'

describe('NewApplications', () => {
  const wrapper = shallow(<NewApplications />)

  it('has automatic as initial option', () => {
    expect(wrapper.state().currentOption).toEqual('automatic')
  })

  it('has automatic form', () => {
    const automaticForm = wrapper.find(AutomaticForm)

    expect(automaticForm).toHaveLength(1)
  })

  it('has manual form', () => {
    const manualForm = wrapper.find(Form)

    expect(manualForm).toHaveLength(1)
  })


  it('dont should display edit image modal', () => {
    expect(wrapper.state().editAvatarModalIsOpen).toBeFalsy()
  })

  describe('when render pills', () => {
    const pills = wrapper.find(Pills)

    it('exists', () => {
      expect(pills).toHaveLength(1)
    })

    it('has automatic option', () => {
      expect(pills.find('[value="automatic"]')).toHaveLength(1)
    })

    it('has manual option', () => {
      expect(pills.find('[value="manual"]')).toHaveLength(1)
    })

    describe('when click in manual option', () => {
      it('set current option to manual', () => {
        wrapper.find('[value="manual"]').simulate('click')

        expect(wrapper.state().currentOption).toEqual('manual')
      })

      it('shows manual form', () => {
        const manualForm = wrapper.find(Form)

        expect(manualForm.props().visibility).toBeTruthy()
      })

      it('hiddens automatic form', () => {
        const automaticForm = wrapper.find(AutomaticForm)

        expect(automaticForm.props().visibility).toBeFalsy()
      })
    })

    describe('when click in automatic option', () => {
      it('set current option to automatic', () => {
        wrapper.find('[value="automatic"]').simulate('click')

        expect(wrapper.state().currentOption).toEqual('automatic')
      })

      it('hiddens manual form', () => {
        const manualForm = wrapper.find(Form)

        expect(manualForm.props().visibility).toBeFalsy()
      })

      it('shows automatic form', () => {
        const automaticForm = wrapper.find(AutomaticForm)

        expect(automaticForm.props().visibility).toBeTruthy()
      })
    })
  })
})

What machine are you on and what's under the hood? How do you run Jest?
Some info would be helpful

Closing this, but we can keep the discussion about the speed going.

Sorry for the delay. My machine is a mac mini. 8Gb RAM, i5.

My package.json (ejected from create-react-app):

{
  "name": "template",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "apiaryio": "^1.0.5",
    "autoprefixer": "6.5.1",
    "babel-core": "6.17.0",
    "babel-eslint": "7.1.1",
    "babel-jest": "18.0.0",
    "babel-loader": "6.2.7",
    "babel-preset-react-app": "^2.0.1",
    "case-sensitive-paths-webpack-plugin": "1.1.4",
    "chalk": "1.1.3",
    "connect-history-api-fallback": "1.3.0",
    "cross-spawn": "4.0.2",
    "css-loader": "0.26.0",
    "detect-port": "1.0.1",
    "directory-to-s3": "^1.0.0-rc4",
    "dotenv": "2.0.0",
    "drakov": "^1.0.1",
    "enzyme": "^2.7.0",
    "eslint": "3.8.1",
    "eslint-config-react-app": "^0.5.0",
    "eslint-loader": "1.6.0",
    "eslint-plugin-flowtype": "2.21.0",
    "eslint-plugin-import": "2.0.1",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.4.1",
    "extract-text-webpack-plugin": "1.0.1",
    "file-loader": "0.9.0",
    "filesize": "3.3.0",
    "fs-extra": "0.30.0",
    "gzip-size": "3.0.0",
    "html-webpack-plugin": "2.24.0",
    "http-proxy-middleware": "0.17.2",
    "jest": "18.1.0",
    "json-loader": "0.5.4",
    "nock": "^9.0.2",
    "node-sass": "^4.2.0",
    "object-assign": "4.1.0",
    "path-exists": "2.1.0",
    "postcss-loader": "1.0.0",
    "promise": "7.1.1",
    "react-addons-test-utils": "^15.4.2",
    "react-dev-utils": "^0.4.2",
    "recursive-readdir": "2.1.0",
    "redux-mock-store": "^1.2.1",
    "sass-loader": "^4.1.1",
    "strip-ansi": "3.0.1",
    "style-loader": "0.13.1",
    "url-loader": "0.5.7",
    "webpack": "1.14.0",
    "webpack-dev-server": "1.16.2",
    "webpack-manifest-plugin": "1.1.0",
    "whatwg-fetch": "1.0.0"
  },
  "dependencies": {
    "axios": "^0.15.3",
    "dotenv": "^2.0.0",
    "hyperable": "git+ssh://[email protected]/ubeedev/hyperable.git",
    "immutable": "^3.8.1",
    "material-design-icons": "^2.2.3",
    "moment": "^2.17.1",
    "react": "^15.4.1",
    "react-addons-css-transition-group": "^15.4.2",
    "react-addons-shallow-compare": "^15.4.2",
    "react-dates": "^4.3.2",
    "react-dom": "^15.4.1",
    "react-helmet": "^3.3.0",
    "react-md-spinner": "^0.2.0",
    "react-outlet": "^1.0.7",
    "react-redux": "^5.0.1",
    "react-router": "^3.0.0",
    "recharts": "^0.20.2",
    "redux": "^3.6.0",
    "redux-form": "^6.5.0",
    "redux-root": "git+ssh://[email protected]/ubeedev/redux-root.git",
    "redux-thunk": "^2.1.0",
    "s3-browser-direct-upload": "^0.1.2",
    "supernova-inloco": "git+ssh://[email protected]/ubeedev/supernova.git#master",
    "uuid": "^3.0.1"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "deploy": "node scripts/deploy.js",
    "test": "node scripts/test.js --env=jsdom",
    "apiary:update": "./node_modules/.bin/apiary fetch publisherapps b1cb81f102063e2cee467a2154db9fb8 --path=apiary.apib",
    "start:mock": "npm run apiary:update & ./node_modules/.bin/drakov -f apiary.apib -p 4007 --autoOptions"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>[/\\\\](build|docs|node_modules|deploy|scripts)[/\\\\]"
    ],
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\](node_modules|deploy)[/\\\\].+\\.(js|jsx)$"
    ],
    "modulePathIgnorePatterns": [
      "<rootDir>[/\\\\](build|docs|node_modules|deploy|scripts)[/\\\\]"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "modulePaths": [
      "src"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

Best suggestion was to set roots config property: https://jestjs.io/docs/en/configuration#roots-array-string

Was this page helpful?
0 / 5 - 0 ratings