Is there special config required to run tests with...
# webassembly
e
Is there special config required to run tests with wasmJs? I keep getting the following error:
Copy code
WARN [web-server]: 404: /absolute/tmp/_karma_webpack_402441/8433c6b69bfa201b0895.wasm > 0 tests completed
Disconnected (0 times) , because no message in 30000 ms.
when running
./gradlew :module:wasmJsBrowserTest
Edit: https://youtrack.jetbrains.com/issue/KT-67468
i
Did you try workaround from the issue? Did it help? If no, could you please share information about your build?
e
Yes it worked, thank you!
👍 1
a
I was facing this issue. I managed to fix it with the workaround from the issue. And it work on my machine but somehow still fails on CI (github actions) Any other workarround? My
karma.config.d/config.js
looks like this
Copy code
// see <https://kotlinlang.org/docs/js-project-setup.html#webpack-configuration-file>
// This file provides karma.config.d configuration to run tests with k/wasm

const path = require("path");

config.browserConsoleLogOptions.level = "debug";

const basePath = config.basePath;
const projectPath = path.resolve(basePath, "..", "..", "..", "..");
const generatedAssetsPath = path.resolve(projectPath, "build", "karma-webpack-out")

const debug = message => console.log(`[karma-config] ${message}`);

debug(`karma basePath: ${basePath}`);
debug(`karma generatedAssetsPath: ${generatedAssetsPath}`);

config.proxies["/"] = path.resolve(basePath, "kotlin");

config.files = [
    {pattern: path.resolve(generatedAssetsPath, "**/*"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.png"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.gif"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.ttf"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.txt"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.json"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.xml"), included: false, served: true, watched: false},
    {pattern: path.resolve(basePath, "kotlin", "**/*.wasm"), included: false, served: true, watched: false},
].concat(config.files);

function KarmaWebpackOutputFramework(config) {
    // This controller is instantiated and set during the preprocessor phase.
    const controller = config.__karmaWebpackController;

    // only if webpack has instantiated its controller
    if (!controller) {
        console.warn(
            "Webpack has not instantiated controller yet.\n" +
            "Check if you have enabled webpack preprocessor and framework before this framework"
        )
        return
    }

    config.files.push({
        pattern: `${controller.outputPath}/**/*`,
        included: false,
        served: true,
        watched: false
    })
}

const KarmaWebpackOutputPlugin = {
    'framework:webpack-output': ['factory', KarmaWebpackOutputFramework],
};

config.plugins.push(KarmaWebpackOutputPlugin);
config.frameworks.push("webpack-output");