Jasmine 为什么;[网络服务器]:404:/absoluteC";当运行业力时

Jasmine 为什么;[网络服务器]:404:/absoluteC";当运行业力时,jasmine,karma-jasmine,karma-runner,web-component,karma-mocha,Jasmine,Karma Jasmine,Karma Runner,Web Component,Karma Mocha,我发现了几个类似的问题,但没有一个建议解决了我的问题。基本上,他们建议添加一些依赖项(我只使用原生webcomponents,因此它不适用于我的案例)或检查路径。我仔细检查,路径是100%正确的。我觉得有点奇怪,警告信息显示的是绝对的,而不是真正的路径。顺便说一句,这条路真的很直 全部代码 Karma.conf.js module.exports = function(config) { config.set({ frameworks: ["jasmine"],

我发现了几个类似的问题,但没有一个建议解决了我的问题。基本上,他们建议添加一些依赖项(我只使用原生webcomponents,因此它不适用于我的案例)或检查路径。我仔细检查,路径是100%正确的。我觉得有点奇怪,警告信息显示的是绝对的,而不是真正的路径。顺便说一句,这条路真的很直

全部代码

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上运行,所以它无法深入查看您的项目。相反,它劫持您的组件,并假设所有内容都可以从该端口访问(它不是)

你可以