I have 2 samples Mocha web tests which I\'m trying to run using Velocity.
For some reason, client-side tests under the /tests/mocha/client folder are never executed
I ran into this problem and it was related to having the browser-policy package installed.
What you need to do is look in the JavaScript console, e.g. in Chrome developer tools, look at the console tab. (Apple Key + option key + I). You should see errors like this:
Refused to frame '
http://localhost:5000/?mocha=true
' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.
You should still have this package installed for security purposes, but for a test do the following:
meteor remove browser-policy
meteor
I would guess that you see your client tests running now? In my case I saw them as soon as I removed the browser-policy package. Basically what you need to do at this point is to tweak your browser policy settings for your application to allow the iframe for mocha, e.g. http://localhost:5000
, but only for the development environment.
Before changing the code put back the browser-policy package.
meteor add browser-policy
Now make the changes to your browser policy settings:
// Your browser policy settings, e.g.
// BrowserPolicy.content...
// Need to run this at the end so that it overrides normal broswer policy settings.
if (process.env.NODE_ENV === "development")
{
console.log("In development mode. Allowing all framing so that mocha-web can run for tests.");
this.BrowserPolicy.content.allowOriginForAll("localhost:*");
this.BrowserPolicy.content.allowConnectOrigin("ws://localhost:5000");
this.BrowserPolicy.content.allowConnectOrigin("ws://localhost:3000");
}