升级版本0.8.0后gulp mocha phantomjs出现问题

升级版本0.8.0后gulp mocha phantomjs出现问题,phantomjs,gulp,mocha.js,mocha-phantomjs,Phantomjs,Gulp,Mocha.js,Mocha Phantomjs,升级到gulp mocha phantomjs版本0.8.0后,我遇到了一些问题: 1)通过url对远程服务器运行时出错: Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///D:/MyDev/ljs_app/trunk/periscope/build/node_modules/gulp-mocha-phant mjs/node_modules/mocha-phant

升级到gulp mocha phantomjs版本0.8.0后,我遇到了一些问题:

1)通过url对远程服务器运行时出错:

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///D:/MyDev/ljs_app/trunk/periscope/build/node_modules/gulp-mocha-phant
mjs/node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js. Domains, protocols and ports must match.
在对远程URL运行测试时,出现以下错误:

ReferenceError: Can't find variable: Mocha
   at browser-shim.js:27
runner.html中的所有必需文件似乎都可用,并且测试在实际浏览器(如FF或Chrome)中按预期工作

runner.html:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Mocha Test Runner</title>
        <link rel="stylesheet" href="HTTP://localhost:7777/q/p/lj_unittest/test/mocha.css">
        <link rel="stylesheet" href="HTTP://localhost:7777/q/p/lj_unittest/css/core.css">
    </head>
    <body>
        <div id="mocha"></div>

        <div id="fixture" style="display:none;">
            <div id="charset_ascii"> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</div>
            <div id="charset_other">ÄäÆæß</div>
        </div>

        <script src="HTTP://localhost:7777/q/p/lj_unittest/js/core.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/mocha.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/chai.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/chai-datetime.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/sinon.js"></script>

        <script>
            mocha.setup("bdd");
        </script>

        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/backend/ods/charset_backend.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/backend/ods/ods.log_backend.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/backend/ods/date.js"></script>

        <script>
            mocha.run();
        </script>
    </body>
</html>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Mocha Test Runner</title>
        <link rel="stylesheet" href="../../../libs/mocha/mocha.css">
        <link rel="stylesheet" href="../../../dist/css/core.css">
    </head>
    <body>
        <div id="mocha"></div>
        <div id="fixture" style="display:none;"></div>
        <script src="../../../dist/js/core.js"></script>
        <script src="../../../libs/mocha/mocha.js"></script>
        <script src="../../../libs/chai/chai.js"></script>
        <script src="../../../libs/chai/chai-datetime.js"></script>
        <script src="../../../libs/sinon/sinon.js"></script>

        <script>
            mocha.setup('bdd');
        </script>

        <!-- START of actual unit test scripts -->
        <script src="./json.js"></script>
        <script src="./moment.js"></script>
        <script src="./underscore.js"></script>
        <!-- END of actual unit test scripts -->

        <script>
            mocha.run();
        </script>
    </body>
</html>
}))

2)一些(但不是全部)基于
runner.html的测试中出现奇怪的警告:

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///D:/MyDev/ljs_app/trunk/periscope/build/node_modules/gulp-mocha-phant
mjs/node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js. Domains, protocols and ports must match.
runner.html:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Mocha Test Runner</title>
        <link rel="stylesheet" href="HTTP://localhost:7777/q/p/lj_unittest/test/mocha.css">
        <link rel="stylesheet" href="HTTP://localhost:7777/q/p/lj_unittest/css/core.css">
    </head>
    <body>
        <div id="mocha"></div>

        <div id="fixture" style="display:none;">
            <div id="charset_ascii"> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~</div>
            <div id="charset_other">ÄäÆæß</div>
        </div>

        <script src="HTTP://localhost:7777/q/p/lj_unittest/js/core.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/mocha.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/chai.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/chai-datetime.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/sinon.js"></script>

        <script>
            mocha.setup("bdd");
        </script>

        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/backend/ods/charset_backend.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/backend/ods/ods.log_backend.js"></script>
        <script src="HTTP://localhost:7777/q/p/lj_unittest/test/backend/ods/date.js"></script>

        <script>
            mocha.run();
        </script>
    </body>
</html>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Mocha Test Runner</title>
        <link rel="stylesheet" href="../../../libs/mocha/mocha.css">
        <link rel="stylesheet" href="../../../dist/css/core.css">
    </head>
    <body>
        <div id="mocha"></div>
        <div id="fixture" style="display:none;"></div>
        <script src="../../../dist/js/core.js"></script>
        <script src="../../../libs/mocha/mocha.js"></script>
        <script src="../../../libs/chai/chai.js"></script>
        <script src="../../../libs/chai/chai-datetime.js"></script>
        <script src="../../../libs/sinon/sinon.js"></script>

        <script>
            mocha.setup('bdd');
        </script>

        <!-- START of actual unit test scripts -->
        <script src="./json.js"></script>
        <script src="./moment.js"></script>
        <script src="./underscore.js"></script>
        <!-- END of actual unit test scripts -->

        <script>
            mocha.run();
        </script>
    </body>
</html>

感谢您的帮助

首先加载
mocha.js
。你自己的评论是正确的

相关的:

首先加载
mocha.js
。你自己的评论是正确的

相关的:

ad 1)通过在任何其他js代码之前加载mocha.js,问题自行解决。我不明白为什么,但它确实有帮助。ad 1)通过在任何其他js代码之前加载mocha.js,问题自行解决了。我不明白为什么,但它确实有帮助。