Les tests Jasmine passent en Chrome et Firefox mais échouent avec PhantomJS

Je construis une application de blog basique avec React. J'utilise Jasmine et Karma pour exécuter mes tests de front. J'ai eu mon premier test opérationnel et il passe en Chrome (Chromium) et Firefox, mais quand il fonctionne dans PhantomJS, j'ai l'erreur suivante:

PhantomJS 1.9.8 (Linux 0.0.0) ERROR TypeError: 'undefined' is not a function (evaluating 'ReactElementValidator.createElement.bind( null, type )') at /home/michael/repository/short-stories/test/karma_tests/story_test.js:1742 

Mon fichier de test ressemble à ceci:

 var React = require('react/addons'); var Story = require('../../app/js/components/story.jsx'); var TestUtils = React.addons.TestUtils; var testUtilsAdditions = require('react-testutils-additions'); describe('Story component', function () { var component; beforeEach(function () { component = TestUtils.renderIntoDocument(React.createElement('story')); component.props.storyTitle = 'front end test title'; component.props.author = 'front end author'; component.props.storyText = 'front end story text'; }); it('should display a story', function () { expect(component.props).toBeDefined(); expect(component.props.storyTitle).toBeDefined(); expect(component.props.storyTitle).toBe('front end test title'); expect(component.props.author).toBe('front end author'); expect(component.props.storyText).toBe('front end story text') }); }); 

J'ai essayé de supprimer mes node_modules, et le cache npm est clair et npm, mais cela ne l'a pas corrigé. Je ne sais pas comment mes tests pourraient passer dans Firefox et Chrome, mais pas dans PhantomJS. Vous pouvez voir le projet complet ici: https://github.com/mrbgit/short-stories . Permettez-moi de savoir s'il y a plus d'informations qui pourraient vous aider. Toute aide est appréciée. Merci!

PhantomJS utilise une version assez ancienne de Qt-Webkit qui ne fournit pas Function.prototype.bind . C'est un problème pour beaucoup de bibliothèques, donc un module NPF polyfill appelé «phantomjs-polyfill» est disponible.

Si vous préférez ne pas utiliser de modules NPM (si vous testez un site de navigateur qui n'a pas été regroupé avec browserify / webpack), le polyfill suivant pour bind est fourni sur la page MDN et vous pouvez l'attacher vous-même:

 if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { if (typeof this !== 'function') { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function() {}, fBound = function() { return fToBind.apply(this instanceof fNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; }