Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Jasmine中找到脚本SRC_Javascript_Unit Testing_Jasmine_Karma Jasmine - Fatal编程技术网

Javascript 如何在Jasmine中找到脚本SRC

Javascript 如何在Jasmine中找到脚本SRC,javascript,unit-testing,jasmine,karma-jasmine,Javascript,Unit Testing,Jasmine,Karma Jasmine,我对Jasmine真的很陌生,正在尝试编写一个单元测试,检查URL是否正确地由环境定义的变量构造 describe('URL is built properly', function() { var newHead = '<!doctype html>' + '<html class="no-js" lang="">' + ' <head>' + ' </

我对Jasmine真的很陌生,正在尝试编写一个单元测试,检查URL是否正确地由环境定义的变量构造

describe('URL is built properly', function() {
        var newHead = '<!doctype html>' +
            '<html class="no-js" lang="">' +
            '    <head>' +
            '    </head>' +
            '<body>' +
            '</body>' +
            '</html>';

        beforeEach(function() {
            ScratchPad.clear();
            ScratchPad.add(newHead);
            debugger;
            spyOn(newSetup.prototype, 'createNewScript');
        });
        afterAll(function() {
            ScratchPad.clear();
        });

        it('should build Staging', function() {
            window.my.env = 'staging';
            window.my = {
                newScript: {
                    enabled: true,
                    location: 'google-com'
                }
            };

            var options = {
                windowWidth: 640
            };

            this.newScript = new newScriptSetup(options);
            var newHTML = ScratchPad.find('script')[0].src;
            debugger;
            expect(newHTML.src).toEqual('http://my.site.com/google-com/myScript.min.js');
        });
    });
脚本的这一部分没有被填充,我已经试着调试它,并且正在创建var newHead,只是单元测试的其余部分没有看到它。。。我想。有人能帮我一下吗,我已经看了一整天了:(

您已经在newHTML中获得了
src
。您正在尝试使用您提供的url检查.src.src。请尝试以下操作:

var newHTML = ScratchPad.find('script')[0].src;
expect(newHTML).toBe(..
var newHTML = ScratchPad.find('script')[0].src;
debugger;
expect(newHTML.src)..
var newHTML = ScratchPad.find('script')[0].src;
expect(newHTML).toBe(..