私はzombiejs + mochaを使用して、DOMを操作するライブラリのいくつかのテストを作成しています。これは、document.createElement()などのJavaScriptネイティブ関数を使用しています。私の問題は、テストを実行すると、「document is not」という例外が発生することです定義されています。
それはzombiejsの問題ですか、それともjsDOMの問題ですか? どうすれば修正できますか?
ここに私のコードの例があります:
HTML:
<!DOCTYPE html>
<html>
  <head>
    <script src="mocha.js"></script>
    <script src="expect.js"></script>
    <title>XS UI Tests</title>
    <script type="text/javascript" charset="utf-8" src="../lib/mylibrary.js"></script>
    <script>
      mocha.setup('bdd');
    </script>
  </head>
  <body>
    <div id="table"></div>
    <div id="controls"></div>
    <div id="form"></div>
    <div id="mocha"></div>
    <script src="tests.js"></script>
  </body>
</html>
tests.js で:
var expect  = require( 'expect.js' )
  , Zombie  = require( 'zombie'    )
  , browser = new Zombie( { debug: true } )
;
describe( 'XS UI Tests:', function() {
  before( function( done ) {
    browser.visit( 'http://localhost:8080/test/ui.html', done );
  } );
  it( 'expect ui.html to be loaded', function() {
    expect( browser.success ).to.be( true );
  } );
  describe( 'Table Tests:', function() {
    it( 'expect div#table ( table container ) to exist', function() {
      expect( browser.query( "#table" ) ).to.be.ok();
    } );
  } );
} );
ご協力ありがとうございました