Created
November 17, 2016 04:50
-
-
Save pgraham/51084903667496ffa6e8215e21d463d5 to your computer and use it in GitHub Desktop.
babel, deamdify bug demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"spec_dir": "target", | |
"spec_files": [ "test-bundle.js" ], | |
"stopSpecOnExpectationFailure": false, | |
"randome": false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>') | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function (require) { | |
var React = require("react"); | |
return React.createClass({ | |
render: function () { | |
return <div className="my-cmp" {...this.props}>YO!</div>; | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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