Skip to content

Instantly share code, notes, and snippets.

@pgraham
Created November 17, 2016 04:50
Show Gist options
  • Save pgraham/51084903667496ffa6e8215e21d463d5 to your computer and use it in GitHub Desktop.
Save pgraham/51084903667496ffa6e8215e21d463d5 to your computer and use it in GitHub Desktop.
babel, deamdify bug demo
{
"spec_dir": "target",
"spec_files": [ "test-bundle.js" ],
"stopSpecOnExpectationFailure": false,
"randome": false
}
var MyComponent = require("MyComponent");
var React = require("react");
describe("views/MyComponent", function () {
it("renders", function () {
var el = React.createElement(MyComponent, {
style: { color: "#000" }
});
var mkup = React.renderToStaticMarkup(el);
expect(mkup).toEqual('<div class="my-cmp" style="color:#000">YO!</div>')
});
});
define(function (require) {
var React = require("react");
return React.createClass({
render: function () {
return <div className="my-cmp" {...this.props}>YO!</div>;
}
});
});
{
"name": "babel-demo",
"version": "0.0.1",
"devDependencies": {
"babel-preset-react": "^6.16.0",
"babelify": "^7.3.0",
"browserify": "^13.0.1",
"deamdify": "github:jaredhanson/deamdify",
"jasmine": "^2.5.2",
"react": "^0.13.1"
},
"scripts": {
"test": "./run-tests.sh"
}
}
set -e
#==============================================================================
# Test Runner
# -----------
#
# Compile test specs using browserify and then run the jasmine unit test suite
# against the required bundle.
#
# This allows requirejs to be preserved for the client but allows test code to
# take advantage of npm modules.
#==============================================================================
if [ ! -d target ]; then
mkdir target
fi
# Compile test sources.
NODE_PATH browserify \
-t [ babelify --presets [ react ] ] \
-t [ deamdify --extensions .js,.jsx ] \
--extension=.jsx \
--debug \
MyComponent-spec.js \
> target/test-bundle.js
# Run tests
JASMINE_CONFIG_PATH=jasmine.json jasmine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment