el-davo / webpack-react-typescript-boilerplate

Webpack React Typescript Boilerplate
9 stars 2 forks source link

errors running with mochista #14

Open laggingreflex opened 7 years ago

laggingreflex commented 7 years ago

I was trying this out (feature/mochista branch) to better understand that issue https://github.com/laggingreflex/mochista/issues/12 but I'm getting these errors:

  mochista:log   Globing files... +0ms
  mochista:log   Readying watcher... +192ms
  mochista:warn  Timed out waiting for watcher "ready" event. Proceeding anyway... (See #chokidar issue in the README) +3s
  mochista:log   Loading compilers... +13ms
  mochista:log   Loading requires... +118ms
  mochista:log   Running mocha... +8s
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
  mochista:error Invariant Violation: injectTapEventPlugin(): Can only be called once per application lifecycle.
  mochista:error
  mochista:error It is recommended to call injectTapEventPlugin() just before you call ReactDOM.render(). If you are using an external library which calls injectTapEventPlugin() itself, please contact the maintainer as it shouldn't be called in library code and should be injected by the application.
  mochista:error ___Stack trace #1___
  mochista:error Invariant Violation: injectTapEventPlugin(): Can only be called once per application lifecycle.
  mochista:error
  mochista:error It is recommended to call injectTapEventPlugin() just before you call ReactDOM.render(). If you are using an external library which calls injectTapEventPlugin() itself, please contact the maintainer as it shouldn't be called in library code and should be injected by the application.
  mochista:error     at invariant (C:\...\webpack-react-typescript-boilerplate\node_modules\fbjs\lib\invariant.js:44:15)
  mochista:error     at injectTapEventPlugin (C:\...\webpack-react-typescript-boilerplate\node_modules\react-tap-event-plugin\src\injectTapEventPlugin.js:11:5)
  mochista:error     at Object.<anonymous> (C:\...\webpack-react-typescript-boilerplate\app\index.tsx:12:1)
  mochista:error     at Module._compile (module.js:571:32)
  mochista:error     at Module.m._compile (C:\...\webpack-react-typescript-boilerplate\node_modules\ts-node\src\index.ts:410:23)
  mochista:error     at Module._extensions..js (module.js:580:10)
  mochista:error     at Object.require.extensions.(anonymous function) [as .tsx] (C:\...\webpack-react-typescript-boilerplate\node_modules\ts-node\src\index.ts:413:12)
  mochista:error     at Module.load (module.js:488:32)
  mochista:error     at tryModuleLoad (module.js:447:12)
  mochista:error     at Function.Module._load (module.js:439:3)
  mochista:error     at Module.require (module.js:498:17)
  mochista:error     at require (internal/module.js:20:19)
  mochista:error     at C:\...\mochista\node_modules\mocha\lib\mocha.js:230:27
  mochista:error     at Array.forEach (native)
  mochista:error     at Mocha.loadFiles (C:\...\mochista\node_modules\mocha\lib\mocha.js:227:14)
  mochista:error     at Mocha.run (C:\...\mochista\node_modules\mocha\lib\mocha.js:495:10) +14s

Commenting out https://github.com/el-davo/webpack-react-typescript-boilerplate/blob/feature/mochista/app/index.tsx#L12 got rid of the above error but then the following error occurred:

  mochista:log   Globing files... +0ms
  mochista:log   Readying watcher... +222ms
  mochista:warn  Timed out waiting for watcher "ready" event. Proceeding anyway... (See #chokidar issue in the README) +4s
  mochista:log   Loading compilers... +20ms
  mochista:log   Loading requires... +198ms
  mochista:log   Running mocha... +10s
Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
action %c@@router/LOCATION_CHANGE %c@ 22:58:56.063
action %c@@router/LOCATION_CHANGE %c@ 22:58:56.063
  mochista:error TypeError: logger[prevStateLevel] is not a function
  mochista:error ___Stack trace #1___
  mochista:error TypeError: logger[prevStateLevel] is not a function
  mochista:error     at C:\...\webpack-react-typescript-boilerplate\node_modules\redux-logger\lib\core.js:116:51
  mochista:error     at Array.forEach (native)
  mochista:error     at printBuffer (C:\...\webpack-react-typescript-boilerplate\node_modules\redux-logger\lib\core.js:69:10)
  mochista:error     at C:\...\webpack-react-typescript-boilerplate\node_modules\redux-logger\lib\index.js:117:31
  mochista:error     at C:\...\webpack-react-typescript-boilerplate\node_modules\react-router-redux\lib\middleware.js:22:18
  mochista:error     at C:\...\webpack-react-typescript-boilerplate\node_modules\redux-saga\lib\internal\middleware.js:86:22
  mochista:error     at Object.dispatch (C:\...\webpack-react-typescript-boilerplate\node_modules\redux-immutable-state-invariant\dist\index.js:52:32)
  mochista:error     at handleLocationChange (C:\...\webpack-react-typescript-boilerplate\node_modules\react-router-redux\lib\sync.js:99:11)
  mochista:error     at Object.syncHistoryWithStore (C:\...\webpack-react-typescript-boilerplate\node_modules\react-router-redux\lib\sync.js:108:5)
  mochista:error     at Object.<anonymous> (C:\...\webpack-react-typescript-boilerplate\app\index.tsx:15:17)
  mochista:error     at Module._compile (module.js:571:32)
  mochista:error     at Module.m._compile (C:\...\webpack-react-typescript-boilerplate\node_modules\ts-node\src\index.ts:410:23)
  mochista:error     at Module._extensions..js (module.js:580:10)
  mochista:error     at Object.require.extensions.(anonymous function) [as .tsx] (C:\...\webpack-react-typescript-boilerplate\node_modules\ts-node\src\index.ts:413:12)
  mochista:error     at Module.load (module.js:488:32)
  mochista:error     at tryModuleLoad (module.js:447:12) +13s

Any idea why these errors might be occurring, or is it only at my end? I'm on Windows 10

el-davo commented 7 years ago

Hi @laggingreflex thanks for opening this one. I cant seem to reproduce it on my end, im also on windows 10. Can you confirm that you installed all the npm dependencies with yarn? Can you also confirm that the following scripts run correctly.

npm test npm run test:watch npm run coverage

el-davo commented 7 years ago

hi @laggingreflex I took a closer look.

TLDR The issue is , you can re-pull and it should work

The issue was that because I am including test-setup.ts it is calling injectTapEventPlugin(). index.tsx is also calling this and this seems to be a violation as it should only be called once. For the moment i have exluded index.tsx from source files with --source-files-exclude=./app/index.tsx. This is probably better as it was trying to load up the whole app. Let me know if there are still issues

el-davo commented 7 years ago

Closing due to inactivity, please feel free to re-open and we can take another crack at this, in the meantime im happy to proceed without mochista

laggingreflex commented 7 years ago

The error was due to mochista not being able to parse correctly the mocha.opts file (as I myself suggested here), and I think I've since fixed it (probably in https://github.com/laggingreflex/mochista/commit/8c8070f76edaed532d602ea9b07eb80b9b524127) but other than it did end up working in the end.

el-davo commented 7 years ago

Nice!, Will take another look when i get some free time