Closed doberkofler closed 8 years ago
I cannot seem to get a most basic mocha-phantomjs-core example to work as expected.
This very simple example works as expected when running in a browser but fails with the following output when run from the command line:
2016-05-10T08:13:41 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persistent cookie storage) 2016-05-10T08:13:42 [DEBUG] Set "http" proxy to: "" : 1080 2016-05-10T08:13:42 [DEBUG] Phantom - execute: Configuration 2016-05-10T08:13:42 [DEBUG] 0 objectName : "" 2016-05-10T08:13:42 [DEBUG] 1 cookiesFile : "" 2016-05-10T08:13:42 [DEBUG] 2 diskCacheEnabled : "false" 2016-05-10T08:13:42 [DEBUG] 3 maxDiskCacheSize : "-1" 2016-05-10T08:13:42 [DEBUG] 4 diskCachePath : "" 2016-05-10T08:13:42 [DEBUG] 5 ignoreSslErrors : "false" 2016-05-10T08:13:42 [DEBUG] 6 localUrlAccessEnabled : "true" 2016-05-10T08:13:42 [DEBUG] 7 localToRemoteUrlAccessEnabled : "false" 2016-05-10T08:13:42 [DEBUG] 8 outputEncoding : "UTF-8" 2016-05-10T08:13:42 [DEBUG] 9 proxyType : "http" 2016-05-10T08:13:42 [DEBUG] 10 proxy : ":1080" 2016-05-10T08:13:42 [DEBUG] 11 proxyAuth : ":" 2016-05-10T08:13:42 [DEBUG] 12 scriptEncoding : "UTF-8" 2016-05-10T08:13:42 [DEBUG] 13 webSecurityEnabled : "true" 2016-05-10T08:13:42 [DEBUG] 14 offlineStoragePath : "" 2016-05-10T08:13:42 [DEBUG] 15 localStoragePath : "" 2016-05-10T08:13:42 [DEBUG] 16 localStorageDefaultQuota : "-1" 2016-05-10T08:13:42 [DEBUG] 17 offlineStorageDefaultQuota : "-1" 2016-05-10T08:13:42 [DEBUG] 18 printDebugMessages : "true" 2016-05-10T08:13:42 [DEBUG] 19 javascriptCanOpenWindows : "true" 2016-05-10T08:13:42 [DEBUG] 20 javascriptCanCloseWindows : "true" 2016-05-10T08:13:42 [DEBUG] 21 sslProtocol : "default" 2016-05-10T08:13:42 [DEBUG] 22 sslCiphers : "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA:ECD HE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-AES256-SHA:AES 128-GCM-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:RC4-SHA:RC4-MD5" 2016-05-10T08:13:42 [DEBUG] 23 sslCertificatesPath : "" 2016-05-10T08:13:42 [DEBUG] 24 sslClientCertificateFile : "" 2016-05-10T08:13:42 [DEBUG] 25 sslClientKeyFile : "" 2016-05-10T08:13:42 [DEBUG] 26 sslClientKeyPassphrase : "" 2016-05-10T08:13:42 [DEBUG] 27 webdriver : ":" 2016-05-10T08:13:42 [DEBUG] 28 webdriverLogFile : "" 2016-05-10T08:13:42 [DEBUG] 29 webdriverLogLevel : "INFO" 2016-05-10T08:13:42 [DEBUG] 30 webdriverSeleniumGridHub : "" 2016-05-10T08:13:42 [DEBUG] Phantom - execute: Script & Arguments 2016-05-10T08:13:42 [DEBUG] script: "node_modules\\mocha-phantomjs-core\\mocha-phantomjs-core.js" 2016-05-10T08:13:42 [DEBUG] 0 arg: "index.html" 2016-05-10T08:13:42 [DEBUG] Phantom - execute: Starting normal mode 2016-05-10T08:13:42 [DEBUG] WebPage - setupFrame "" ... (error) {\n return error\n }\n})(\"spec\"); })()" 2016-05-10T08:13:42 [DEBUG] WebPage - evaluateJavaScript result QVariant(bool, true) 2016-05-10T08:13:42 [DEBUG] Callback - call result: QVariant(bool, true) mocha.run() was called with no tests 2016-05-10T08:13:42 [DEBUG] WebPage - setupFrame "" 2016-05-10T08:13:42 [DEBUG] WebPage - updateLoadingProgress: 100 2016-05-10T08:13:42 [DEBUG] WebPage - updateLoadingProgress: 10 2016-05-10T08:13:42 [DEBUG] WebPage - setupFrame "" 2016-05-10T08:13:42 [DEBUG] WebPage - updateLoadingProgress: 100 2016-05-10T08:13:42 [DEBUG] WebPage - setupFrame "" 2016-05-10T08:13:42 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r"))) 2016-05-10T08:13:42 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r"))) 2016-05-10T08:13:42 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r"))) 2016-05-10T08:13:42 [DEBUG] WebPage - updateLoadingProgress: 10 2016-05-10T08:13:42 [DEBUG] WebPage - setupFrame "" 2016-05-10T08:13:42 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r"))) 2016-05-10T08:13:42 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r"))) 2016-05-10T08:13:42 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r"))) 2016-05-10T08:13:42 [DEBUG] WebPage - updateLoadingProgress: 100 2016-05-10T08:13:42 [DEBUG] Callback - call result: QVariant(bool, true)
package.json:
{ "name": "mocha", "version": "1.0.0", "description": "mocha", "scripts": { "test": "phantomjs --debug=true node_modules\\mocha-phantomjs-core\\mocha-phantomjs-core.js index.html" }, "author": "", "license": "ISC", "repository": {}, "dependencies": { "chai": "^3.5.0", "mocha": "^2.4.5", "mocha-phantomjs-core": "^1.3.1", "phantomjs": "^2.1.7" } }
index.html:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>test</title> <link rel="stylesheet" href="node_modules/mocha/mocha.css"> </head> <body> <div id="mocha"></div> <script src="node_modules/mocha/mocha.js"></script> <script src="node_modules/chai/chai.js"></script> <script> mocha.ui("bdd"); </script> <script src="index.js"></script> <script> mocha.run(); </script> </body> </html>
index.js:
'use strict'; const assert = chai.assert; describe('addition', function () { it('should add two numbers', function () { const n = 7 * 3; assert.strictEqual(n, 21); }); });
Any help would be appreciated.
You are trying to run ES6 in an ES5 browser. (const is ES6)
const
@nathanboktae Thank you so much for your help! I just did not see it. May I just ask if there is a way to find this kind of script errors?
I cannot seem to get a most basic mocha-phantomjs-core example to work as expected.
This very simple example works as expected when running in a browser but fails with the following output when run from the command line:
package.json:
index.html:
index.js:
Any help would be appreciated.