angular.js - angular 指令中包含webworker 在单元测试中一直报找不到worker 文件错误 如何解决?
漂亮男人
漂亮男人 2017-05-15 16:52:26
[AngularJS讨论组]
//directive.js
 var option = {
      'typeNumber': 4,
       'errorCorrectLevel':'L',
       'text': $scope.text
    }
$scope.worker = new Worker('/js/myworkers.js');
$scope.myworker.postMessage(option);

//test.js
describe('Directives test', function(){
    var $compile, $scope, $templateCache, $httpBackend,workerValue,$timeout;
    beforeEach(module('directives'));
    ...
    ...
    ...
it('qrcode test', function(){
        $httpBackend.expectGET('webroot/js/myworkers.js').respond(200,'woker');
        var link = $compile('<my-qrcode value="qrcode_text" change="false"></my-qrcode>');
        var element = link($scope);
        $scope.$digest();
        console.log(element.html());
        //expect(element.html()).toEqual(workerValue)
});

//karma.conf.js
...
    // list of files / patterns to load in the browser
    files: [
    'testjs/jquery.js',
    'webroot/js/lib/angular/angular.js',
    'webroot/js/lib/angular/angular-route.js',
    // 'webroot/js/lib/angular/angular-animate.js',
    'webroot/js/lib/angular/angular-resource.js',

    'webroot/js/lib/angular/angular-sanitize.js',
    'webroot/js/lib/angular/*.min.js',
    'webroot/js/lib/bootstrap-ui/*.js',
    // 'webroot/js/lib/angular/angular-loader.js',
    'webroot/js/lib/angular/angular-mocks.js',
    'webroot/js/myworkers.js',
    'webroot/js/bootstrap.js',
    'webroot/js/services.js',
    'webroot/js/directives.js',
    'webroot/js/filters.js',
    'webroot/js/app.js',
    'webroot/js/controllers.js',
    'testjs/*.js'
    ],
 ...


 

报错报错提示

][2]

debug中的 resource

我看到有人说 这样就可以了
但是现在不行
谁能说说这是什么情况吗??怎么解决呢??

漂亮男人
漂亮男人

全部回复(1)
世界只因有你

..把路径写好就好了。。。。 new work("base/webroot/js/myworker.js")

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号