mocha-phantomjs-core
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -17,3 +17,6 @@ (function(){ | ||
var scriptTags = document.querySelectorAll('script'), | ||
mochaScript = scriptTags[scriptTags.length - 1] | ||
mochaScript = Array.prototype.filter.call(scriptTags, function(s) { | ||
var src = s.getAttribute('src') | ||
return src && src.match(/mocha\.js$/) | ||
})[0] | ||
@@ -40,2 +43,3 @@ function isFileReady(readyState) { | ||
mocha.run = function() { | ||
window.callPhantom({ testRunStarted: mocha.suite.suites.length }) | ||
mocha.runner = origRun.apply(mocha, arguments) | ||
@@ -42,0 +46,0 @@ if (mocha.runner.stats && mocha.runner.stats.end) { |
@@ -9,2 +9,3 @@ var | ||
configured = false, | ||
runStarted = false, | ||
hookData | ||
@@ -85,3 +86,3 @@ | ||
page.onResourceReceived = function(resource) { | ||
if (resource.url.match(/mocha\.js/)) { | ||
if (resource.url.match(/mocha\.js$/)) { | ||
page.injectJs('browser-shim.js') | ||
@@ -98,2 +99,7 @@ } | ||
configureMocha() | ||
} else if ('testRunStarted' in data) { | ||
if (data.testRunStarted == 0) { | ||
fail('mocha.run() was called with no tests') | ||
} | ||
runStarted = true | ||
} else if (data.testRunEnded) { | ||
@@ -116,3 +122,10 @@ if (typeof config.hooks.afterEnd === 'function') { | ||
} else if (!configured) { | ||
fail('Failed to run any tests.') | ||
fail('mocha was not initialized before the page finished loading. Make sure to include mocha.js as a direct script and call `mocha.ui` or `mocha.setup`.') | ||
} else if (!runStarted) { | ||
var timeout = config.timeout || 10000 | ||
setTimeout(function() { | ||
if (!runStarted) { | ||
fail('mocha.run() was not called within ' + timeout + 'ms of the page loading.') | ||
} | ||
}, timeout) | ||
} | ||
@@ -119,0 +132,0 @@ } |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"author": "Nathan Black <nathan@nathanblack.org> (https://github.com/nathanboktae)", | ||
@@ -39,4 +39,5 @@ "licenses": [ | ||
"co-mocha": "^1.1.0", | ||
"coffee-script": "^1.9.1" | ||
"coffee-script": "^1.9.1", | ||
"requirejs": "^2.1.20" | ||
} | ||
} |
@@ -49,2 +49,6 @@ # Run Mocha tests in PhantomJS | ||
#### `timeout` | ||
Time in milliseconds after the page loads that `mocha.run` needs to be called. Defaults to 10 seconds. | ||
#### `viewportSize` | ||
@@ -51,0 +55,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
273
125
0
20133
5
8