茉莉花注入不起作用

Itrulia

因此,我有一个使用Typescript编译的angular 1.5应用程序,然后通过Browserify将其捆绑。

现在,当我想使用Karma和Jasmine对其进行测试时,一旦我要注入服务,就会收到一条错误消息(在启用了strict-di的浏览器中,它可以正常工作)。

有人看到错误在哪里吗?

CacheServiceTest.ts

import {CacheService} from "../../../app/services/CacheService";
import {Application} from "../../../app/Application";

describe("AppComponent", () => {
    beforeEach(() => {
        angular.mock.module(Application.name);
    });

    it("should contain CacheService", () => {
        inject((CacheService:CacheService) => {
            console.log(CacheService);
        });
    });
});

业力配置

module.exports = function (config) {
    config.set({
        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: "..",

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ["jasmine", "browserify"],

        // list of files / patterns to load in the browser
        files: [
            "node_modules/angular/angular.js",
            "node_modules/angular-mocks/angular-mocks.js",
            "node_modules/ngLeague/dist/ngLeague.js",
            "node_modules/angular-localforage/dist/angular-localForage.js",
            "app/**/*.ts",
            "tests/unit/**/*.ts",

            // JSON fixture
            {
                pattern:  "tests/fixtures/**/*.json",
                watched:  true,
                served:   true,
                included: false
            }
        ],

        // list of files to exclude
        exclude: [],

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {
            "app/**/*.ts": ["browserify", "ng-annotate"],
            "tests/unit/**/*.ts": ["browserify", "ng-annotate"],
            "dist/ngCache.js": "coverage"
        },

        // Browserify config
        browserify: {
            debug: true,
            plugin: [
                ["tsify", {target: "ES5"}]
            ]
        },

        // test results reporter to use
        // possible values: "dots", "progress"
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ["progress", "coverage"],

        coverageReporter: {
            type : "html",
            dir : "tests/coverage/"
        },

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ["PhantomJS"],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false
    });
};

错误

forEach@/home/kme/Documents/ngCache/node_modules/angular/angular.js:322:24
    loadModules@/home/kme/Documents/ngCache/node_modules/angular/angular.js:4548:12
    createInjector@/home/kme/Documents/ngCache/node_modules/angular/angular.js:4470:30
    workFn@/home/kme/Documents/ngCache/node_modules/angular-mocks/angular-mocks.js:2954:60
    inject@/home/kme/Documents/ngCache/node_modules/angular-mocks/angular-mocks.js:2934:46
    /tmp/fe42636aeb0f927c8dcd9afa7c80f051.browserify:16447:15 <- tests/unit/services/CacheServiceTest.ts:14:15
    /home/kme/Documents/ngCache/node_modules/angular/angular.js:4588:53
Itrulia

未加载localforage,du。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

茉莉花注入不起作用

来自分类Dev

简单的流星方法茉莉花测试不起作用

来自分类Dev

Angular 5 茉莉花表单提交不起作用

来自分类Dev

依赖注入在角度/浏览器/业力/茉莉花单元测试中不起作用

来自分类Dev

茉莉花测试中的角度元素上的调度事件不起作用

来自分类Dev

茉莉花自定义匹配器不起作用

来自分类Dev

茉莉花SpyOn haveBeenCalled上的函数引用不起作用(Angular)

来自分类Dev

量角器/茉莉花测试browser.isElementPresent在查找类时不起作用

来自分类Dev

茉莉花 html 报告器中的 Cleandestination 不起作用

来自分类Dev

茉莉花:监视由另一个函数调用的导出的函数不起作用

来自分类Dev

Angular 2可观察服务业力茉莉花单元测试不起作用

来自分类Dev

如何向茉莉花注入服务

来自分类Dev

茉莉花间谍

来自分类Dev

茉莉花(通过TypeScript)测试来验证作用域$ on

来自分类Dev

茉莉花间谍在jquery

来自分类Dev

茉莉花:此范围

来自分类Dev

茉莉花间谍NodeJS

来自分类Dev

茉莉花测试,addEventListener

来自分类Dev

Angular +茉莉花测试

来自分类Dev

茉莉花链测试

来自分类Dev

尝试/赶上茉莉花

来自分类Dev

茉莉花装置与iframe

来自分类Dev

茉莉花间谍命名

来自分类Dev

茉莉花间谍法

来自分类Dev

茉莉花测试失败

来自分类Dev

茉莉花测试-优先

来自分类Dev

模拟茉莉花的承诺

来自分类Dev

茉莉花可变范围

来自分类Dev

茉莉花规格失败