为什么"[[网络服务器]:404:/absoluteC""运行业力时 [英] why "[web-server]: 404: /absoluteC" when running karma

查看:78
本文介绍了为什么"[[网络服务器]:404:/absoluteC""运行业力时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了几个类似的问题,但是没有一个建议可以解决我的问题.基本上,他们建议添加一些依赖项(我仅使用本机Web组件,因此不适用于我的情况)或检查路径.我仔细检查,路径是100%正确.我发现警告消息在实际路径之前显示为绝对,这有点奇怪.顺便说一句,这条路真的很完美.

I found several similar question but none of the suggestions fixed my issue. Basically they are suggesting add some dependency (I am using only native webcomponents so it doesn't appliy to my case) or check the path. I checked carefully and the path is 100% correct. I found a bit strange that the warnning message shows absolute before the real path. BTW, the path is really coorect.

整个代码 github

Karma.conf.js

Karma.conf.js

module.exports = function(config) {
    config.set({
        frameworks: ["jasmine"],
        files: [
            "../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js",
            { pattern: "../test/*-test.js", type: "module", included: true }
        ],
        exclude: [],
        preprocessors: {},
        reporters: ["spec"],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ["Chrome"],
        singleRun: true,
        concurrency: Infinity
    });
};

控制台消息

# npm test

> sktscanner-flight-search@0.1.0 test C:\_d\WSs\rapidapi-vanilla-webcomponents\skyscanner-webcomponents
> karma start config/karma.conf.js

06 08 2019 19:22:55.229:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
06 08 2019 19:22:55.251:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
06 08 2019 19:22:55.261:INFO [launcher]: Starting browser Chrome
06 08 2019 19:22:58.972:INFO [Chrome 75.0.3770 (Windows 10.0.0)]: Connected on socket xwPc3314bVDtrBgaAAAA with id 78516319
06 08 2019 19:22:59.161:WARN [web-server]: 404: /absoluteC:/_d/WSs/rapidapi-vanilla-webcomponents/skyscanner-webcomponents/public/skyscanner-flight-search/skyscanner-flight-search.js
06 08 2019 19:22:59.165:WARN [web-server]: 404: /absoluteC:/_d/WSs/rapidapi-vanilla-webcomponents/skyscanner-webcomponents/test/test-utils.js

Chrome 75.0.3770 (Windows 10.0.0): Executed 0 of 0 ERROR (0.008 secs / 0 secs)

npm ERR! Test failed.  See above for more details.

单元测试

import { SkyscannerFlightSearch } from "../public/skyscanner-flight-search/skyscanner-flight-search.js";
import { TestUtils } from "./test-utils.js";
describe("simplest test", () => {
    it("first try (using TestUtils)", async() => {
        const { shadowRoot } = await TestUtils.render("skyscanner-flight-search");
        expect(shadowRoot.querySelector("#firstdiv")).toBeTruthy();
    });
});

推荐答案

由于Karma默认运行在端口9876上,因此它无法深入研究您的项目.相反,它劫持了您的组件,并假设所有内容都可以从该端口访问(不是)....

Because Karma by default runs on port 9876, it doesn't have ability to look too deep into your project. Instead it hijacks your component and assumes everything is accessible from that port (which it is not)....

您可以使用本指南将Karma重定向到您的真实端口"

这篇关于为什么"[[网络服务器]:404:/absoluteC""运行业力时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆