codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 221 forks source link

Process is not defined #531

Closed Eternal-Rise closed 2 years ago

Eternal-Rise commented 2 years ago

Actual Behavior

$ npm run test:browser

> mathjs@10.1.1 test:browser
> karma start test/browser-test-config/local-karma.js

START:
Webpack bundling...
asset commons.js 5.8 MiB [emitted] (name: commons) (id hint: commons)
asset runtime.js 7.49 KiB [emitted] (name: runtime)
asset browser-tests.test.3563922937.js 1.02 KiB [emitted] (name: browser-tests.test.3563922937)
asset global-variables.3987379921.js 1.02 KiB [emitted] (name: global-variables.3987379921)Entrypoint global-variables.3987379921 5.81 MiB = runtime.js 7.49 KiB commons.js 5.8 MiB global-variables.3987379921.js 1.02 KiB
Entrypoint browser-tests.test.3563922937 5.81 MiB = runtime.js 7.49 KiB commons.js 5.8 MiB browser-tests.test.3563922937.js 1.02 KiB
webpack 5.69.1 compiled successfully in 31227 ms
20 02 2022 21:27:44.794:INFO [karma-server]: Karma v6.3.13 server started at http://localhost:9876/
20 02 2022 21:27:44.797:INFO [launcher]: Launching browsers FirefoxHeadless with concurrency unlimited
20 02 2022 21:27:44.807:INFO [launcher]: Starting browser FirefoxHeadless
20 02 2022 21:27:46.864:INFO [Firefox 97.0 (Windows 10)]: Connected on socket ZfbwFGXCUq3c0FBoAAAB with id 92906822
Firefox 97.0 (Windows 10) ERROR
  ReferenceError: process is not defined
  at C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/commons.js line 549 > eval:109:5

  @webpack://mathjs/./node_modules/util/util.js?:109:5
  ./node_modules/util/util.js@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/commons.js:549:1
  __webpack_require__@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:31:42
  @webpack://mathjs/./node_modules/assert/build/internal/assert/assertion_error.js?:35:35
  ./node_modules/assert/build/internal/assert/assertion_error.js@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/commons.js:39:1
  __webpack_require__@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:31:42
  @webpack://mathjs/./node_modules/assert/build/assert.js?:36:41
  ./node_modules/assert/build/assert.js@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/commons.js:28:1
  __webpack_require__@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:31:42
  @webpack://mathjs/./test/unit-tests/approx.test.js?:2:83
  ./test/unit-tests/approx.test.js@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/commons.js:7220:1
  __webpack_require__@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:31:42
  webpackContext@webpack://mathjs/./test/unit-tests/_sync_.test\.js$?:287:9
  @webpack://mathjs/./test/browser-test-config/browser-tests.test.js?:3:21
  ./test/browser-test-config/browser-tests.test.js@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/commons.js:601:1
  __webpack_require__@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:31:42
  __webpack_exec__@browser-tests.test.3563922937.js:12:67
  @browser-tests.test.3563922937.js:13:71
  __webpack_require__.O@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:80:23
  @browser-tests.test.3563922937.js:14:56
  webpackJsonpCallback@C:/Users/Kazuy/AppData/Local/Temp/_karma_webpack_839742/runtime.js:172:46
  @browser-tests.test.3563922937.js:10:65

Code

karma-config https://github.com/Eternal-Rise/mathjs/blob/feat/migrate-to-webpack-5/test/browser-test-config/base-karma.js

How Do We Reproduce?

  1. Clone repo https://github.com/Eternal-Rise/mathjs/tree/feat/migrate-to-webpack-5
  2. Switch to branch git switch feat/migrate-to-webpack-5
  3. install packages npm ci
  4. run browser tests npm run test:browser
Eternal-Rise commented 2 years ago

Fixed by adding process to karma/webpack config

plugins: [
  new webpack.ProvidePlugin({
        process: 'process'
  })
],