';
+
+const BUTTON_MARKUP =
+ 'Edit in eXeLearning';
+
+// WordPress puts jQuery on the page as a global; the IIFE closes over it by name.
+const $ = require( 'jquery' );
+global.jQuery = $;
+
+// Each copy of the script binds a native `message` listener on window and never
+// unbinds it, so record every registration in order to drop them between tests.
+const windowMessageListeners = [];
+const realAddEventListener = window.addEventListener.bind( window );
+window.addEventListener = ( type, listener, options ) => {
+ if ( type === 'message' ) {
+ windowMessageListeners.push( { listener, options } );
+ }
+ realAddEventListener( type, listener, options );
+};
+
+let loadCount = 0;
+
+/**
+ * Load a fresh copy of the editor script against the given markup.
+ *
+ * @param {string} markup Body markup for the screen under test.
+ * @return {Promise