Skip to content

KT-87304: Update karma.conf.js to use 'require(...)' instead plain strings#6499

Open
Anton Lakotka (antohaby) wants to merge 1 commit into
masterfrom
alakotka/KT-87304_jsBrowserTest_fix
Open

KT-87304: Update karma.conf.js to use 'require(...)' instead plain strings#6499
Anton Lakotka (antohaby) wants to merge 1 commit into
masterfrom
alakotka/KT-87304_jsBrowserTest_fix

Conversation

@antohaby

Copy link
Copy Markdown
Contributor

Fixes KT-87304

@kodee-bot

kodee-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

This MR fixes the regression, but the root cause is not yet documented as required by the guideline
Please update the commit message to include a description of the root cause, using one of the following prefixes: ^RCA:, #RCA:.

This will allow our automation to copy the RCA into the issue comments and automatically apply the root-cause-defined tag.

@kotlin-safemerge

kotlin-safemerge Bot commented Jul 2, 2026

Copy link
Copy Markdown

Code Owners

RuleOwnersApproval
/​libraries/​tools/​kotlin-​gradle-​plugin-​integration-​tests/​, /​libraries/​tools/​kotlin-​gradle-​plugin/​
kotlin-build-tools

adam-enko, Tapchicoma
/​libraries/​tools/​kotlin-​gradle-​plugin/​src/​common/​kotlin/​org/​jetbrains/​kotlin/​gradle/​targets/​js/​
kotlin-build-tools
kotlin-wasm

ilgonmic

@antohaby

Copy link
Copy Markdown
Contributor Author

/dry-run

@KotlinBuild

This comment has been minimized.

…ings

The karma tool treats plain strings differently that commonJs module
specification.
KGP uses workspaces model that leverages commonJs module system
when searching for modules to load.

i.e. when kotlin-web-helpers got installed to some inner
workspace package
(`js/packages/kmp-lib-test/node_modules/kotlin-web-helpers`)
then code in kmp-lib-test that requires kotlin-web-helpers should find it.

the kotlin-web-helpers can also be placed in the upper node_modules
(`js/node_modules/kotlin-web-helpers`).

But when karma plugin is passed as plain string, 'my-plugin/plugin.js'
karma will look up for it only in the upper node_modules of the
root npm project.

So when all inner packages had the kotlin-web-helpers in their node_modules
but not in the root one, karma will fail because it can't find it.

But karma config is a js script that can use commonJS module system.
And it should do it, as any other js tooling code.

^KT-87304 Verification Pending
@KotlinBuild Build Server (KotlinBuild) force-pushed the alakotka/KT-87304_jsBrowserTest_fix branch from 4b30772 to 6cc360c Compare July 2, 2026 22:21
@antohaby

Copy link
Copy Markdown
Contributor Author

/dry-run

@KotlinBuild

Build Server (KotlinBuild) commented Jul 2, 2026

Copy link
Copy Markdown

THIS IS A DRY RUN

Quality gate is triggered at https://buildserver.labs.intellij.net/build/992306819 — use this link to get full insight.

Quality gate was triggered with the following revisions:

kotlin
Branch: refs/merge/GITHUB-6499/safe-merge
Commit: ec1b2ab


Quality gate finished successfully.

"""
config.plugins = config.plugins || [];
config.plugins.push('kotlin-web-helpers/dist/karma-kotlin-reporter.js');
config.plugins.push(require('kotlin-web-helpers/dist/karma-kotlin-reporter'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why it might not be installed in root node_modules...
And I am sure that Karma does it on its side (https://github.com/karma-runner/karma/blob/84f85e7016efc2266fa6b3465f494a3fa151c85c/lib/plugin.js#L17)
However it requires the module related to karma which is supposed to be installed in root node_modules, so agree it is not equivalent things, require here and in karma package

rootLevelWebHelpers.moveTo(packageLevelWebHelpers)

// -x kotlinNpmInstall to prevent overwriting
if (isTeamCityRun) { // Should be fixed by KTI-3326, but only in master branch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that it will work for karma even with the new configurations. There are no pre-bundled browsers on agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants