Skip to content

Instantly share code, notes, and snippets.

@cirocosta
Last active March 15, 2016 19:23
Show Gist options
  • Save cirocosta/2292f88e54d40ba3e936 to your computer and use it in GitHub Desktop.
Save cirocosta/2292f88e54d40ba3e936 to your computer and use it in GitHub Desktop.
Testing mocha with flow annotations
'use strict';
var fs = require('fs');
var ReactTools = require('react-tools');
var fn = module.exports = function () {
require.extensions['.js'] = function (module, filename) {
module._compile(
ReactTools.transform(
fs.readFileSync(filename, 'utf8'),
{stripTypes: true, harmony: true}),
filename)
};
};
fn();
// example of a flow globals file
declare var SC: Object;
type StatesType = {[key: string]: {
value: any;
elem: HTMLElement;
attach: ?{
[key: string]: (s: StatesType, e: Event) => void};
draw: (elem: HTMLElement, value: any) => void;
}};
{
"name": "something-cool",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:es6-flow-transform && flow check --lib flow/globals.js"
},
"author": "Ciro S. Costa <[email protected]> (http://cirocosta.github.io/)",
"license": "MIT",
"devDependencies": {
"react-tools": "^0.12.2",
"mocha": "^2.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment