mzgoddard / jest-webpack

Use jest with webpack.
https://www.npmjs.com/package/jest-webpack
92 stars 21 forks source link

path issues #19

Open OneCyrus opened 7 years ago

OneCyrus commented 7 years ago

my project with typescript has some issues with paths. don't know what's happening there?!

> jest-webpack

[at-loader] Using typescript@2.4.2 from typescript and "tsconfig.json" from C:\Users\xyz\Source\Repos\prj1\src\subprj/tscon
fig.json.

 FAIL  Scripts\tests\widget.test.tsx
  ● Test suite failed to run

    C:\Users\xyz\Source\Repos\prj1\src\subprj\.cache\jest-webpack\Scripts\tests\widget.test.tsx:130
      "9aae9945f5e2ce3e1e4abce75aca702f15d58bfb": function() {return __webpack_require__(./Scripts/tests/widget.test.tsx);}
                                                                                         ^

    SyntaxError: Unexpected token .

      at ScriptTransformer._transformAndBuildScript (../../node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
      at handle (../../node_modules/worker-farm/lib/child/index.js:44:8)
      at process.<anonymous> (../../node_modules/worker-farm/lib/child/index.js:51:3)
      at emitTwo (events.js:125:13)

the corresponding code in widget.test.tsx (webpacked). shouldn't the argument be a string?

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {

module.exports = {
  "9aae9945f5e2ce3e1e4abce75aca702f15d58bfb": function() {return __webpack_require__(./Scripts/tests/widget.test.tsx);}
};
module.exports["9aae9945f5e2ce3e1e4abce75aca702f15d58bfb"]();
dantman commented 6 years ago

I'm getting a similar error:

 FAIL  build/default/src/responsive-editor/js/store/__tests__/Responsivetemplate.mjs
  ● Test suite failed to run

    /Users/daniel/Workspace/work/AgreementExpress/TemplateBuilder/src/main/webapp/.cache/jest-webpack/build/default/src/responsive-editor/js/store/__tests__/Responsivetemplate.mjs: Unexpected token (81:85)
        79 | 
        80 | module.exports = {
      > 81 |   "8fbf8d85b48eb51e8ccaff72ecb60611ce5f48ec": function() {return __webpack_require__(./build/default/src/responsive-editor/js/store/__tests__/Responsivetemplate.mjs);}
           |                                                                                      ^
        82 | };
        83 | module.exports["8fbf8d85b48eb51e8ccaff72ecb60611ce5f48ec"]();
        84 | 

Config:

  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "jsx",
      "node",
      "mjs"
    ],
    "testMatch": [
      "**/__tests__/**/*.js?(x)",
      "**/__tests__/**/*.mjs"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/__tests__/_\\w+/"
    ],
    "transform": {
      "^.+\\.jsx?$": "babel-jest",
      "^.+\\.mjs$": "babel-jest"
    }
  },
    devtool: isDevelopment ? 'cheap-module-eval-source-map' : false,
    entry: {
        app: './src/app/main.mjs',
    },
    resolve: {
        extensions: ['.js', '.mjs', '.jsx', '.mjsx', '.json'],
    },
    module: {
        loaders: [
            {
                test: /\.m?jsx?$/,
                exclude: s => /node_modules/.test(s) && !/react-polymer/.test(s),
                loader: 'babel-loader',
            }
        ],
    },
    output: {
        path: path.join(__dirname, 'bundles'),
        filename: '[name].js',
    },