mardi 21 février 2017

Jest resolve extensions

I have serveral webpack config files, let's say webpack.native.js and webpack.web.js, each one has different resolve, where depending on the script, it will bundle with app.native.js or app.web.js into bundle.js.

Now with Jest + enzyme for testing, is it possible to have similar "resolve"?

The ideal would be, having npm web:test and npm native:test and it will resolve and test the corresponding platform code.

my current config: (it runs all, but it causes problem where it found some platform specific code)

 "jest": {
    "collectCoverageFrom": [
      "main/shared/**/*.{js,jsx}",
      "!main/**/*.test.{js,jsx}",
      "!main/App.js",
      "!main/**/index.js",
      "!**/node_modules/**"
    ],
    "moduleFileExtensions": ["js", "jsx"],
    "moduleDirectories": [
      "node_modules",
      "main"
    ],
    "moduleNameMapper": {
      "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js"

    },
    "testRegex": "(tests.*|\\.(test|spec))\\.(js|jsx)$"
  }

Aucun commentaire:

Enregistrer un commentaire