import React from 'react/addons'; import Note from '../app/components/notes/Notes'; var TestUtils = React.addons.TestUtils; describe('Note', () => { var component; beforeEach(() => { component = TestUtils.renderIntoDocument(<Note username="zhentian-wan" />); }); it('should display the correct artist name', () => { expect(React.findDOMNode(component).textContent).toMatch(/Notes for zhentian-wan/); }); });
index.htmlcss
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Jasmine Spec Runner</title> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine-html.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/boot.min.js"></script> <script src="spec.js"></script> </head> <body></body> </html>
Webpack.config.jshtml
module.exports = { entry: "./NotesSpec.js", output: { filename: "spec.js" }, module: { loaders: [ { test: /\.js?$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader' } ] } };