gocd / gocd

GoCD - Continuous Delivery server main repository

Home Page:https://www.gocd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade Jasmine + friends to v5

chadlwilson opened this issue · comments

Summary

Currently we use Jasmine 4.6. jasmine v5 is out, however seems to have some kind of issue with either jasmine-karma or our use of webpack.

Steps to Reproduce
  1. Upgrade jasmine, jasmine-core to 5.0.0+, upgrade jasmine-browser-runner to 2.0.0+
  2. Run ./gradlew jasmineKarma
Expected Results

Tests should work :-)

Actual Results
> Task :server:jasmineKarma FAILED
const stringWidth = require('string-width');
[/go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails]$ yarn run jasmine-ci
                    ^
yarn run v1.22.19

$ karma start --single-run
Error [ERR_REQUIRE_ESM]: require() of ES Module /go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/string-width/index.js from /go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs not supported.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Instead change the require of index.js in /go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs:291:21)
    at Object.<anonymous> (/go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/yargs/build/index.cjs:2861:12)
    at Object.<anonymous> (/go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/yargs/index.cjs:5:30)
    at Object.<anonymous> (/go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/karma/lib/cli.js:4:15)
    at Object.<anonymous> (/go/pipelines/build-linux-pull_11645/server/src/main/webapp/WEB-INF/rails/node_modules/karma/bin/karma:3:1) {
  code: 'ERR_REQUIRE_ESM'
}

/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs:293
const wrap = require('wrap-ansi');
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/wrap-ansi/index.js from /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/cliui/build/index.cjs:293:14)
    at Object.<anonymous> (/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/yargs/build/index.cjs:2861:12)
    at Object.<anonymous> (/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/yargs/index.cjs:5:30)
    at Object.<anonymous> (/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/karma/lib/cli.js:4:15)
    at Object.<anonymous> (/Users/chad/Projects/community/gocd/gocd/server/src/main/webapp/WEB-INF/rails/node_modules/karma/bin/karma:3:1) {
  code: 'ERR_REQUIRE_ESM'
}

Possible Fix
  • May depend on webpack upgrade in #10852 and a general review of our configuration.
  • May also require a replacement or change to our use of karma-jasmine and karma-runner/karma-jasmine#333
  • May relate to cliui's use of aliased dependencies for string-width and string-width-cjs, which is causing confusion. Perhaps better handled in either Yarn v2 or npm?
  warning Pattern ["string-width@^4.1.0"] is trying to unpack in the same destination "/Users/chad/Library/Caches/Yarn/v6/npm-string-width-cjs-4.2.3-269c7117d27b05ad2e536830a8ec895ef9c6d010-integrity/node_modules/string-width-cjs" as pattern ["string-width-cjs@npm:string-width@^4.2.0"]. This could result in non-deterministic behavior, skipping.
warning Pattern ["string-width@^4.2.0"] is trying to unpack in the same destination "/Users/chad/Library/Caches/Yarn/v6/npm-string-width-cjs-4.2.3-269c7117d27b05ad2e536830a8ec895ef9c6d010-integrity/node_modules/string-width-cjs" as pattern ["string-width-cjs@npm:string-width@^4.2.0"]. This could result in non-deterministic behavior, skipping.
warning Pattern ["wrap-ansi@^7.0.0"] is trying to unpack in the same destination "/Users/chad/Library/Caches/Yarn/v6/npm-wrap-ansi-cjs-7.0.0-67e145cff510a6a6984bdf1152911d69d2eb9e43-integrity/node_modules/wrap-ansi-cjs" as pattern ["wrap-ansi-cjs@npm:wrap-ansi@^7.0.0"]. This could result in non-deterministic behavior, skipping.
warning Pattern ["string-width@^4.2.3"] is trying to unpack in the same destination "/Users/chad/Library/Caches/Yarn/v6/npm-string-width-cjs-4.2.3-269c7117d27b05ad2e536830a8ec895ef9c6d010-integrity/node_modules/string-width-cjs" as pattern ["string-width-cjs@npm:string-width@^4.2.0"]. This could result in non-deterministic behavior, skipping.