Debian Codegraph @

extensions/VisualEditor/lib/ve/tests/ve.qunit.local.js

raw symbols SCIP
1 /*!
2 * VisualEditor core-only plugin for QUnit.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 // Extend QUnit.module to provide a fixture element. This used to be in tests/index.html, but
8 // dynamic test runners like Karma build their own web page.
9 ( function ( QUnit ) {
10 const origModule = QUnit.module;
11
12 QUnit.dump.maxDepth = 10;
13
14 QUnit.module = function ( name, localEnv ) {
15 localEnv = localEnv || {};
16 origModule( name, {
17 beforeEach: function () {
18 this.fixture = document.createElement( 'div' );
19 this.fixture.id = 'qunit-fixture';
20 document.body.appendChild( this.fixture );
21
22 this.fixture.appendChild( ve.init.target.$element[ 0 ] );
23
24 if ( localEnv.beforeEach ) {
25 return localEnv.beforeEach.apply( this, arguments );
26 }
27 },
28 afterEach: function () {
29 let res;
30 if ( localEnv.afterEach ) {
31 res = localEnv.afterEach.apply( this, arguments );
32 }
33
34 this.fixture.parentNode.removeChild( this.fixture );
35 return res;
36 }
37 } );
38 };
39 }( QUnit ) );